MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / getTask

Function getTask

cmd/cql-proxy/api/task.go:78–112  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

76}
77
78func getTask(c *gin.Context) {
79 r := struct {
80 ID int64 `json:"id" form:"id" uri:"id" binding:"required"`
81 }{}
82
83 _ = c.ShouldBindUri(&r)
84
85 if err := c.ShouldBind(&r); err != nil {
86 abortWithError(c, http.StatusBadRequest, err)
87 return
88 }
89
90 developer := getDeveloperID(c)
91 task, err := model.GetTask(model.GetDB(c), developer, r.ID)
92 if err != nil {
93 _ = c.Error(err)
94 abortWithError(c, http.StatusForbidden, ErrGetTaskDetailFailed)
95 return
96 }
97
98 responseWithData(c, http.StatusOK, gin.H{
99 "task": func(t *model.Task) gin.H {
100 return gin.H{
101 "id": t.ID,
102 "type": t.Type.String(),
103 "state": t.State.String(),
104 "args": t.Args,
105 "result": t.Result,
106 "created": formatUnixTime(t.Created),
107 "updated": formatUnixTime(t.Updated),
108 "finished": formatUnixTime(t.Finished),
109 }
110 }(task),
111 })
112}
113
114func cancelTask(c *gin.Context) {
115 r := struct {

Callers

nothing calls this directly

Calls 8

GetTaskFunction · 0.92
GetDBFunction · 0.92
abortWithErrorFunction · 0.85
getDeveloperIDFunction · 0.85
responseWithDataFunction · 0.85
formatUnixTimeFunction · 0.85
ErrorMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected