aboutsummaryrefslogtreecommitdiffstats
path: root/services/cron/cron.go
diff options
context:
space:
mode:
Diffstat (limited to 'services/cron/cron.go')
-rw-r--r--services/cron/cron.go36
1 files changed, 26 insertions, 10 deletions
diff --git a/services/cron/cron.go b/services/cron/cron.go
index 19f703caf1..9fe90d4230 100644
--- a/services/cron/cron.go
+++ b/services/cron/cron.go
@@ -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()
}