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") ids := getSQLListID64(r.Query) if len(ids) > 1 { for _, id := range ids { p := JobPayloadRescanMsg{ Query: fmt.Sprintf("SELECT o.id FROM obj o WHERE o.id = %d AND o.obj_type_id = %d AND o.obj_sub_type_id = %d;", id, objTypeMessage, objSubTypeMessageUnknown), } b, _ := json.Marshal(p) err := createJob(objSubTypeJobRescanMsg, objJobPriorityRescanChildMsg, time.Now(), b) logOnError(err, "jobRescan : createJob(objSubTypeJobRescanMsg)") } p := JobPayloadSetDone{ JobID64: j.ID64, } b, _ := json.Marshal(p) err := createJob(objSubTypeJobSetJobDone, objJobPriority, 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)") } else { err = setJobDone(j.ID64) logOnError(err, "jobRescan : setJobDone(0)") } 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") return }