package main import ( "encoding/json" "fmt" "time" ) func jobRescan(j Job) { var r JobPayloadRescanMsg err := setJobStart(j.ID64) logOnError(err, "jobRescan : setJobStart") err = json.Unmarshal(j.Payload, &r) logOnError(err, "jobRescan : Unmarshal payload") start := time.Now() ids := getSQLListID64(r.Query) if len(ids) > 1 { for _, id := range ids { SQLMsgIdentifyQueue <- id } p := JobPayloadSetDone{ JobID64: j.ID64, MsgID64: r.MsgID64, ChatID64: r.ChatID64, Text: fmt.Sprintf("%d messages processed in %s.", len(ids), time.Since(start)), } b, _ := json.Marshal(p) err := createJob(objSubTypeJobSetJobDone, objJobPriorityRescanAllMsg, j.UserID64, time.Now(), b) logOnError(err, "jobRescan : createJob(objSubTypeJobSetJobDone)") } else if len(ids) == 1 { SQLMsgIdentifyQueue <- ids[0] err = setJobDone(j.ID64) logOnError(err, "jobRescan : setJobDone(1)") if r.MsgID64 != 0 || r.ChatID64 != 0 { m := TGCommand{ Type: commandReplyMsg, Text: "One message processed.", FromMsgID64: r.MsgID64, FromChatID64: r.ChatID64, } TGCmdQueue <- m } } else { err = setJobDone(j.ID64) logOnError(err, "jobRescan : setJobDone(0)") if r.MsgID64 != 0 || r.ChatID64 != 0 { m := TGCommand{ Type: commandReplyMsg, Text: "No message processed.", FromMsgID64: r.MsgID64, FromChatID64: r.ChatID64, } TGCmdQueue <- m } } return } func jobSetDone(j Job) { var r JobPayloadSetDone err := setJobStart(j.ID64) logOnError(err, "jobSetDone : setJobStart") err = json.Unmarshal(j.Payload, &r) logOnError(err, "jobSetDone : Unmarshal payload") err = setJobDone(r.JobID64) logOnError(err, "jobSetDone : setJobDone(child)") err = setJobDone(j.ID64) logOnError(err, "jobSetDone : setJobDone") m := TGCommand{ Type: commandReplyMsg, Text: r.Text, FromMsgID64: r.MsgID64, FromChatID64: r.ChatID64, } TGCmdQueue <- m return } func jobPillage(j Job) { /* var r JobPayloadPillage err := setJobStart(j.ID64) logOnError(err, "jobPillage : setJobStart") err = json.Unmarshal(j.Payload, &r) logOnError(err, "jobPillage : Unmarshal payload") ids := getSQLListID64(` select og.id from obj og ,obj_msg omg ,obj op ,obj_msg omp ,obj_job oj where omg.obj_id = og.id and og.obj_sub_type_id = ` + strconv.Itoa(objSubTypeMessageGo) ` and omg.user_id = oj.user_id and omg.sender_user_id = oj.user_id and oj.obj_id = ` + strconv.Itoa(j.ID64) ` and omp.obj_id = op.id and op.id = ` + strconv.Itoa(r.ObjID64) ` and omg.date between omp.date and addtime(omp.date, '0 0:3:0.000000');` err = setJobStatus(j.ID64, objJobStatusPillageGo, time.Now().Add(5 * time.second)) logOnError(err, "jobPillage : setJobDone") */ return }