From c0907b3df5dffd410c5f24faa6712c36f5a88f30 Mon Sep 17 00:00:00 2001 From: zouap Date: Fri, 21 Jan 2022 14:46:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/cloudbrain.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index b84bc3626..662719799 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -336,6 +336,11 @@ func CloudBrainRestart(ctx *context.Context) { } func CloudBrainBenchMarkShow(ctx *context.Context) { + if benchmarkTypes == nil { + if err := json.Unmarshal([]byte(setting.BenchmarkTypes), &benchmarkTypes); err != nil { + log.Error("json.Unmarshal BenchmarkTypes(%s) failed:%v", setting.BenchmarkTypes, err, ctx.Data["MsgID"]) + } + } cloudBrainShow(ctx, tplCloudBrainBenchmarkShow) } @@ -400,7 +405,7 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName) { } else { duration = int64(task.UpdatedUnix) - int64(task.CreatedUnix) } - if benchmarkTypes.BenchmarkType != nil { + if benchmarkTypes != nil { for _, benchmarkType := range benchmarkTypes.BenchmarkType { if task.BenchmarkTypeID == benchmarkType.Id { ctx.Data["BenchmarkTypeName"] = benchmarkType.First