This commit is contained in:
shoopea 2019-05-19 11:20:01 +08:00
parent 8c80e1dc87
commit 3e0370631e
2 changed files with 15 additions and 31 deletions

10
def.go
View File

@ -193,8 +193,7 @@ const (
objSubTypeJobWithdrawal = 604
objSubTypeJobGStock = 605
objSubTypeJobRescanMsg = 606
objSubTypeJobRescanMsgChild = 607
objSubTypeJobSetJobDone = 608
objSubTypeJobSetJobDone = 607
objSubTypeItemResource = 701
objSubTypeItemAlch = 702
objSubTypeItemMisc = 703
@ -207,10 +206,9 @@ const (
objJonStatusPending = 10
objJobStatusDone = 20
objJobPriority = 1
objJobPriorityRescanMsg = 2
objJobPriorityRescanChildMsg = 3
objJobPriorityRescanAllMsg = 4
objJobPriority = 1
objJobPriorityRescanMsg = 2
objJobPriorityRescanAllMsg = 3
MQGetMsgWorkers = 12
MQCWMsgQueueSize = 100

36
job.go
View File

@ -18,33 +18,19 @@ func jobRescan(j Job) {
ids := getSQLListID64(r.Query)
if len(ids) > 1 {
for i := 1; i <= (len(ids)/SQLMsgRescanJobSize)+1; i++ {
var s string
for _, id := range ids[((i - 1) * SQLMsgRescanJobSize) : Min((i*SQLMsgRescanJobSize), len(ids))-1] {
s = s + fmt.Sprintf("SELECT %d id FROM DUAL UNION\n", id)
}
s = s + `SELECT 0 id FROM DUAL WHERE 1 = 2;`
p := JobPayloadRescanMsg{
Query: s,
MsgID64: 0,
ChatID64: 0,
}
b, _ := json.Marshal(p)
err := createJob(objSubTypeJobRescanMsg, objJobPriorityRescanChildMsg, j.UserID64, time.Now(), b)
logOnError(err, "jobRescan : createJob(objSubTypeJobRescanMsg)")
for _, id := range ids {
SQLMsgIdentifyQueue <- id
}
p := JobPayloadSetDone{
JobID64: j.ID64,
MsgID64: r.MsgID64,
ChatID64: r.ChatID64,
Text: fmt.Sprintf("%d messages processed.", len(ids)),
}
b, _ := json.Marshal(p)
err := createJob(objSubTypeJobSetJobDone, objJobPriorityRescanAllMsg, j.UserID64, time.Now(), b)
logOnError(err, "jobRescan : createJob(objSubTypeJobSetJobDone)")
if j.JobTypeID == objSubTypeJobRescanMsg {
p := JobPayloadSetDone{
JobID64: j.ID64,
MsgID64: r.MsgID64,
ChatID64: r.ChatID64,
Text: fmt.Sprintf("%d messages processed.", len(ids)),
}
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)