2018-04-28 17:44:44 +00:00
|
|
|
package jobs
|
|
|
|
|
|
|
|
import (
|
2018-04-28 19:17:44 +00:00
|
|
|
"sort"
|
|
|
|
|
2018-04-28 17:44:44 +00:00
|
|
|
"github.com/aerogo/aero"
|
2019-11-17 07:59:34 +00:00
|
|
|
"github.com/animenotifier/notify.moe/arn"
|
2018-04-28 17:44:44 +00:00
|
|
|
"github.com/animenotifier/notify.moe/components"
|
|
|
|
"github.com/animenotifier/notify.moe/utils"
|
|
|
|
)
|
|
|
|
|
2018-04-28 19:17:44 +00:00
|
|
|
var jobInfo = map[string]*utils.JobInfo{
|
2019-04-23 05:52:55 +00:00
|
|
|
"kitsu-import-anime": {
|
2018-05-08 11:52:07 +00:00
|
|
|
Name: "kitsu-import-anime",
|
|
|
|
},
|
2018-12-06 03:06:37 +00:00
|
|
|
// "anime-ratings": &utils.JobInfo{
|
|
|
|
// Name: "anime-ratings",
|
|
|
|
// },
|
|
|
|
// "twist": &utils.JobInfo{
|
|
|
|
// Name: "twist",
|
|
|
|
// },
|
|
|
|
// "refresh-games": &utils.JobInfo{
|
|
|
|
// Name: "refresh-games",
|
|
|
|
// },
|
|
|
|
// "test": &utils.JobInfo{
|
|
|
|
// Name: "test",
|
|
|
|
// },
|
2018-04-28 19:17:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var jobLogs = []string{}
|
2018-04-28 17:44:44 +00:00
|
|
|
|
|
|
|
// Overview shows all background jobs.
|
2019-06-01 04:55:49 +00:00
|
|
|
func Overview(ctx aero.Context) error {
|
2019-11-17 07:59:34 +00:00
|
|
|
user := arn.GetUserFromContext(ctx)
|
2018-04-28 19:17:44 +00:00
|
|
|
jobs := []*utils.JobInfo{}
|
|
|
|
|
|
|
|
for _, job := range jobInfo {
|
|
|
|
jobs = append(jobs, job)
|
|
|
|
}
|
|
|
|
|
|
|
|
sort.Slice(jobs, func(i, j int) bool {
|
|
|
|
return jobs[i].Name < jobs[j].Name
|
|
|
|
})
|
2018-04-28 17:44:44 +00:00
|
|
|
|
2019-06-01 04:55:49 +00:00
|
|
|
return ctx.HTML(components.EditorJobs(jobs, jobLogs, ctx.Path(), user))
|
2018-04-28 17:44:44 +00:00
|
|
|
}
|