2019-05-11 06:54:12 +02:00
package main
import (
2019-05-11 06:55:05 +02:00
"encoding/json"
2019-05-11 06:54:12 +02:00
"fmt"
2019-05-11 06:55:05 +02:00
"time"
2019-05-11 06:54:12 +02:00
)
2019-05-11 06:54:49 +02:00
func jobRescan ( j Job ) {
2019-05-11 07:06:40 +02:00
var r JobPayloadRescanMsg
2019-05-11 06:54:12 +02:00
err := setJobStart ( j . ID64 )
logOnError ( err , "jobRescan : setJobStart" )
2019-05-11 07:06:40 +02:00
2019-05-11 06:56:48 +02:00
err = json . Unmarshal ( j . Payload , & r )
2019-05-11 07:06:40 +02:00
logOnError ( err , "jobRescan : Unmarshal payload" )
2019-05-11 06:54:12 +02:00
ids := getSQLListID64 ( r . Query )
2019-05-11 07:06:40 +02:00
2019-05-11 06:54:12 +02:00
if len ( ids ) > 1 {
for _ , id := range ids {
2019-05-11 07:20:44 +02:00
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 ) ,
}
2019-05-11 06:54:12 +02:00
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 )
2019-05-11 07:06:40 +02:00
logOnError ( err , "jobRescan : setJobDone(1)" )
} else {
err = setJobDone ( j . ID64 )
logOnError ( err , "jobRescan : setJobDone(0)" )
2019-05-11 06:54:12 +02:00
}
return
}
2019-05-11 06:54:49 +02:00
func jobSetDone ( j Job ) {
2019-05-11 07:06:40 +02:00
var r JobPayloadSetDone
2019-05-11 06:54:12 +02:00
err := setJobStart ( j . ID64 )
logOnError ( err , "jobSetDone : setJobStart" )
2019-05-11 07:06:40 +02:00
2019-05-11 06:56:48 +02:00
err = json . Unmarshal ( j . Payload , & r )
2019-05-11 07:06:40 +02:00
logOnError ( err , "jobSetDone : Unmarshal payload" )
2019-05-11 06:54:12 +02:00
err = setJobDone ( r . JobID64 )
logOnError ( err , "jobSetDone : setJobDone(child)" )
2019-05-11 07:06:40 +02:00
2019-05-11 06:54:12 +02:00
err = setJobDone ( j . ID64 )
logOnError ( err , "jobSetDone : setJobDone" )
2019-05-11 07:06:40 +02:00
2019-05-11 06:54:12 +02:00
return
}