| 37 | ) |
| 38 | |
| 39 | func 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 | |
| 68 | func GetTaskArtifacts(c *gin.Context) { |
| 69 | task, exists, err := model.GetByTaskId(c.GetInt("id"), c.Param("key")) |