mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-25 11:22:16 +00:00
Show last cron messages on monitor page (#19223)
As discussed on #19221 we should store the results of the last task message on the crontask and show them on the monitor page. Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
parent
e69b7a92ed
commit
90e0a402c1
6 changed files with 109 additions and 67 deletions
|
@ -47,11 +47,23 @@ func NewContext() {
|
|||
|
||||
// TaskTableRow represents a task row in the tasks table
|
||||
type TaskTableRow struct {
|
||||
Name string
|
||||
Spec string
|
||||
Next time.Time
|
||||
Prev time.Time
|
||||
ExecTimes int64
|
||||
Name string
|
||||
Spec string
|
||||
Next time.Time
|
||||
Prev time.Time
|
||||
Status string
|
||||
LastMessage string
|
||||
LastDoer string
|
||||
ExecTimes int64
|
||||
task *Task
|
||||
}
|
||||
|
||||
func (t *TaskTableRow) FormatLastMessage(locale string) string {
|
||||
if t.Status == "finished" {
|
||||
return t.task.GetConfig().FormatMessage(locale, t.Name, t.Status, t.LastDoer)
|
||||
}
|
||||
|
||||
return t.task.GetConfig().FormatMessage(locale, t.Name, t.Status, t.LastDoer, t.LastMessage)
|
||||
}
|
||||
|
||||
// TaskTable represents a table of tasks
|
||||
|
@ -80,11 +92,15 @@ func ListTasks() TaskTable {
|
|||
}
|
||||
task.lock.Lock()
|
||||
tTable = append(tTable, &TaskTableRow{
|
||||
Name: task.Name,
|
||||
Spec: spec,
|
||||
Next: next,
|
||||
Prev: prev,
|
||||
ExecTimes: task.ExecTimes,
|
||||
Name: task.Name,
|
||||
Spec: spec,
|
||||
Next: next,
|
||||
Prev: prev,
|
||||
ExecTimes: task.ExecTimes,
|
||||
LastMessage: task.LastMessage,
|
||||
Status: task.Status,
|
||||
LastDoer: task.LastDoer,
|
||||
task: task,
|
||||
})
|
||||
task.lock.Unlock()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue