diff --git a/models/cloudbrain_image.go b/models/cloudbrain_image.go index eb21e0d87..f72c6a27c 100644 --- a/models/cloudbrain_image.go +++ b/models/cloudbrain_image.go @@ -45,7 +45,7 @@ type ImageStar struct { } type ImageTopic struct { - ID int64 + ID int64 `xorm:"pk autoincr"` Name string `xorm:"UNIQUE VARCHAR(105)"` ImageCount int CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"` @@ -468,8 +468,13 @@ func (images ImageList) loadAttributes(e Engine, uid int64) error { } for i := range images { - images[i].UserName = users[images[i].UID].Name - images[i].RelAvatarLink = users[images[i].UID].RelAvatarLink() + if users[images[i].UID] != nil { + images[i].UserName = users[images[i].UID].Name + images[i].RelAvatarLink = users[images[i].UID].RelAvatarLink() + } else { + images[i].UserName = "" + images[i].RelAvatarLink = "" + } if uid == -1 { images[i].IsStar = false } else { diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index b3b07f352..e5a61b9a7 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -491,34 +491,22 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName, jobType models.Jo } } taskRoles := jobRes.TaskRoles - if jobRes.JobStatus.State != string(models.JobFailed) { - - taskRes, _ := models.ConvertToTaskPod(taskRoles[cloudbrain.SubTaskName].(map[string]interface{})) - ctx.Data["taskRes"] = taskRes - task.Status = taskRes.TaskStatuses[0].State - task.ContainerID = taskRes.TaskStatuses[0].ContainerID - task.ContainerIp = taskRes.TaskStatuses[0].ContainerIP - models.ParseAndSetDurationFromCloudBrainOne(jobRes, task) - - if task.DeletedAt.IsZero() { //normal record - err = models.UpdateJob(task) - if err != nil { - ctx.Data["error"] = err.Error() - return - } - } else { //deleted record - + taskRes, _ := models.ConvertToTaskPod(taskRoles[cloudbrain.SubTaskName].(map[string]interface{})) + ctx.Data["taskRes"] = taskRes + ctx.Data["ExitDiagnostics"] = taskRes.TaskStatuses[0].ExitDiagnostics + task.Status = taskRes.TaskStatuses[0].State + task.ContainerID = taskRes.TaskStatuses[0].ContainerID + task.ContainerIp = taskRes.TaskStatuses[0].ContainerIP + models.ParseAndSetDurationFromCloudBrainOne(jobRes, task) + + if task.DeletedAt.IsZero() { //normal record + err = models.UpdateJob(task) + if err != nil { + ctx.Data["error"] = err.Error() + return } - } else { - task.Status = jobRes.JobStatus.State - taskRes := models.TaskPod{TaskStatuses: []models.TaskStatuses{ - { - State: jobRes.JobStatus.State, - }, - }} - ctx.Data["taskRes"] = taskRes - jobRes.JobStatus.StartTime = time.Unix(int64(task.CreatedUnix), 0).Format("2006-01-02 15:04:05") - jobRes.JobStatus.EndTime = time.Unix(int64(task.UpdatedUnix), 0).Format("2006-01-02 15:04:05") + } else { //deleted record + } ctx.Data["result"] = jobRes diff --git a/templates/explore/repo_right.tmpl b/templates/explore/repo_right.tmpl index 12a3ffadb..5e05e797b 100644 --- a/templates/explore/repo_right.tmpl +++ b/templates/explore/repo_right.tmpl @@ -1,4 +1,4 @@ - +