MCPcopy Create free account
hub / github.com/OpenListTeam/OpenList / getTaskInfo

Function getTaskInfo

server/handles/task.go:33–62  ·  view source on GitHub ↗
(task T)

Source from the content-addressed store, hash-verified

31}
32
33func getTaskInfo[T task.TaskExtensionInfo](task T) TaskInfo {
34 errMsg := ""
35 if task.GetErr() != nil {
36 errMsg = task.GetErr().Error()
37 }
38 progress := task.GetProgress()
39 // if progress is NaN, set it to 100
40 if math.IsNaN(progress) {
41 progress = 100
42 }
43 creatorName := ""
44 creatorRole := -1
45 if task.GetCreator() != nil {
46 creatorName = task.GetCreator().Username
47 creatorRole = task.GetCreator().Role
48 }
49 return TaskInfo{
50 ID: task.GetID(),
51 Name: task.GetName(),
52 Creator: creatorName,
53 CreatorRole: creatorRole,
54 State: task.GetState(),
55 Status: task.GetStatus(),
56 Progress: progress,
57 StartTime: task.GetStartTime(),
58 EndTime: task.GetEndTime(),
59 TotalBytes: task.GetTotalBytes(),
60 Error: errMsg,
61 }
62}
63
64func getTaskInfos[T task.TaskExtensionInfo](tasks []T) []TaskInfo {
65 return utils.MustSliceConvert(tasks, getTaskInfo[T])

Callers 3

FsStreamFunction · 0.85
FsFormFunction · 0.85
taskRouteFunction · 0.85

Calls 10

GetProgressMethod · 0.80
GetStateMethod · 0.80
GetCreatorMethod · 0.65
GetIDMethod · 0.65
GetNameMethod · 0.65
GetStartTimeMethod · 0.65
GetEndTimeMethod · 0.65
GetTotalBytesMethod · 0.65
ErrorMethod · 0.45
GetStatusMethod · 0.45

Tested by

no test coverage detected