mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-08 03:00:26 +08:00
优化缓存任务Key状态增加执行中状态
This commit is contained in:
@@ -1 +1,20 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
|
import "encoding/json"
|
||||||
|
|
||||||
|
// DecodeNodes 解析已完成节点信息
|
||||||
|
func (this *HTTPCacheTaskKey) DecodeNodes() map[string]bool {
|
||||||
|
var result = map[string]bool{}
|
||||||
|
var nodesJSON = this.Nodes
|
||||||
|
if IsNull(nodesJSON) {
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
err := json.Unmarshal(nodesJSON, &result)
|
||||||
|
if err != nil {
|
||||||
|
// ignore error
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|||||||
@@ -306,12 +306,14 @@ func (this *HTTPCacheTaskService) FindEnabledHTTPCacheTask(ctx context.Context,
|
|||||||
}
|
}
|
||||||
var pbKeys = []*pb.HTTPCacheTaskKey{}
|
var pbKeys = []*pb.HTTPCacheTaskKey{}
|
||||||
for _, key := range keys {
|
for _, key := range keys {
|
||||||
|
|
||||||
pbKeys = append(pbKeys, &pb.HTTPCacheTaskKey{
|
pbKeys = append(pbKeys, &pb.HTTPCacheTaskKey{
|
||||||
Id: int64(key.Id),
|
Id: int64(key.Id),
|
||||||
TaskId: int64(key.TaskId),
|
TaskId: int64(key.TaskId),
|
||||||
Key: key.Key,
|
Key: key.Key,
|
||||||
KeyType: key.KeyType,
|
KeyType: key.KeyType,
|
||||||
IsDone: key.IsDone,
|
IsDone: key.IsDone,
|
||||||
|
IsDoing: !key.IsDone && len(key.DecodeNodes()) > 0,
|
||||||
ErrorsJSON: key.Errors,
|
ErrorsJSON: key.Errors,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user