MCPcopy Create free account
hub / github.com/QuantumNous/new-api / GetTask

Function GetTask

controller/task.go:39–66  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

37)
38
39func GetTask(c *gin.Context) {
40 task, exists, err := model.GetByTaskId(c.GetInt("id"), c.Param("key"))
41 if err != nil {
42 videoProxyError(c, http.StatusInternalServerError, "server_error", "Failed to query task")
43 return
44 }
45 if !exists {
46 videoProxyError(c, http.StatusNotFound, "invalid_request_error", "Task not found")
47 return
48 }
49 createdAt := task.CreatedAt
50 if createdAt == 0 {
51 createdAt = task.SubmitTime
52 }
53 failReason := task.FailReason
54 if task.Status == model.TaskStatusSuccess && taskFailReasonIsLegacyResultURL(task.FailReason) {
55 failReason = ""
56 }
57 c.JSON(http.StatusOK, gin.H{
58 "task_id": task.TaskID,
59 "platform": task.Platform,
60 "status": task.Status,
61 "progress": task.Progress,
62 "fail_reason": failReason,
63 "created_at": createdAt,
64 "finished_at": task.FinishTime,
65 })
66}
67
68func GetTaskArtifacts(c *gin.Context) {
69 task, exists, err := model.GetByTaskId(c.GetInt("id"), c.Param("key"))

Callers 1

Calls 3

GetByTaskIdFunction · 0.92
videoProxyErrorFunction · 0.85

Tested by 1