This commit is contained in:
shoopea 2019-06-14 12:18:26 +08:00
parent 0e72a8f118
commit 776c5949c2

16
job.go
View File

@ -151,12 +151,12 @@ func loadCurrentJobs() ([]Job, error) {
}
func jobRescan(j Job) {
var r JobPayloadRescanMsg
var p JobPayloadRescanMsg
err := setJobStart(j.ID64)
logOnError(err, "jobRescan : setJobStart")
err = json.Unmarshal(j.Payload, &r)
err = json.Unmarshal(j.Payload, &p)
logOnError(err, "jobRescan : Unmarshal payload")
start := time.Now()
@ -180,10 +180,10 @@ func jobRescan(j Job) {
i = i + 1
if time.Now().After(milestone.Add(1 * time.Minute)) {
txt := fmt.Sprintf("Rescanned %d/%d messages.", i, len(ids))
//txt := fmt.Sprintf("Rescanned %d/%d messages.", i, len(ids))
m = TGCommand{
Type: commandReplyMsg,
Text: txt,
Text: fmt.Sprintf("Rescanned %d/%d messages.", i, len(ids)),
FromMsgID64: p.MsgID64,
FromChatID64: p.ChatID64,
}
@ -193,13 +193,13 @@ func jobRescan(j Job) {
}
p := JobPayloadSetDone{
r := JobPayloadSetDone{
JobID64: j.ID64,
MsgID64: r.MsgID64,
ChatID64: r.ChatID64,
MsgID64: p.MsgID64,
ChatID64: p.ChatID64,
Text: fmt.Sprintf("%d messages processed in %s.", len(ids), time.Since(start)),
}
b, _ := json.Marshal(p)
b, _ := json.Marshal(r)
_, err := createJob(objSubTypeJobSetJobDone, objJobPriorityRescanAllMsg, j.UserID64, time.Now().UTC(), b)
logOnError(err, "jobRescan : createJob(objSubTypeJobSetJobDone)")