From 4f0643b93c9fed2c3d397dcf9770282cdf8c2333 Mon Sep 17 00:00:00 2001 From: yuyuanshifu <747342561@qq.com> Date: Sun, 7 Feb 2021 16:20:44 +0800 Subject: [PATCH] get job status --- routers/api/v1/repo/modelarts.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/routers/api/v1/repo/modelarts.go b/routers/api/v1/repo/modelarts.go index a16274189..1b58a2fab 100755 --- a/routers/api/v1/repo/modelarts.go +++ b/routers/api/v1/repo/modelarts.go @@ -8,6 +8,7 @@ package repo import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" + "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/modelarts" "net/http" ) @@ -19,7 +20,7 @@ func GetModelArtsTask(ctx *context.APIContext) { jobID := ctx.Params(":jobid") repoID := ctx.Repo.Repository.ID - _, err = models.GetRepoCloudBrainByJobID(repoID, jobID) + job, err := models.GetRepoCloudBrainByJobID(repoID, jobID) if err != nil { ctx.NotFound(err) return @@ -30,6 +31,12 @@ func GetModelArtsTask(ctx *context.APIContext) { return } + job.Status = result.Status + err = models.UpdateJob(job) + if err != nil { + log.Error("UpdateJob failed:", err) + } + ctx.JSON(http.StatusOK, map[string]interface{}{ "JobID": jobID, "JobStatus": result.Status,