From 2c579d60cd5a32226266465661335bff40e1897a Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 6 Jun 2022 11:44:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/ai_model_manage.go | 10 +++++++++- routers/api/v1/repo/cloudbrain.go | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/models/ai_model_manage.go b/models/ai_model_manage.go index dec91ef91..115b5b485 100644 --- a/models/ai_model_manage.go +++ b/models/ai_model_manage.go @@ -84,7 +84,15 @@ type AiModelQueryOptions struct { Status int } -func ComputeAndSetDuration(task *AiModelConvert) { +func ModelComputeAndSetDuration(task *AiModelConvert, result JobResultPayload) { + if task.StartTime == 0 { + task.StartTime = timeutil.TimeStamp(result.JobStatus.CreatedTime / 1000) + } + if task.EndTime == 0 { + if result.JobStatus.CompletedTime > 0 { + task.EndTime = timeutil.TimeStamp(result.JobStatus.CompletedTime / 1000) + } + } var d int64 if task.StartTime == 0 { d = 0 diff --git a/routers/api/v1/repo/cloudbrain.go b/routers/api/v1/repo/cloudbrain.go index d3581fb53..94b57fc28 100755 --- a/routers/api/v1/repo/cloudbrain.go +++ b/routers/api/v1/repo/cloudbrain.go @@ -135,7 +135,7 @@ func GetCloudbrainModelConvertTask(ctx *context.APIContext) { } if result.JobStatus.State != string(models.JobWaiting) { - models.ComputeAndSetDuration(job, result) + models.ModelComputeAndSetDuration(job, result) err = models.UpdateModelConvert(job) if err != nil { log.Error("UpdateJob failed:", err)