🎨 改进同步后台任务

This commit is contained in:
Liang Ding 2023-01-27 15:49:55 +08:00
parent f3547465c1
commit 8d64ae6149
No known key found for this signature in database
GPG key ID: 136F30F901A2231D

View file

@ -97,21 +97,23 @@ func StatusJob() {
tasks := taskQueue
data := map[string]interface{}{}
var items []map[string]interface{}
count := map[string]int{}
for _, task := range tasks {
if OCRImage == task.Action || DatabaseIndexEmbedBlock == task.Action {
continue
}
actionLangs := util.TaskActionLangs[util.Lang]
action := task.Action
if c := count[action]; 3 < c {
logging.LogWarnf("too many tasks [%s], ignore show its status", action)
continue
}
count[action]++
if nil != actionLangs {
if label := actionLangs[task.Action]; nil != label {
action = label.(string)
}
}
item := map[string]interface{}{
"action": action,
}
item := map[string]interface{}{"action": action}
items = append(items, item)
}
if 1 > len(items) {