mirror of https://github.com/shunfei/cronsun
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
714 B
31 lines
714 B
package web
|
|
|
|
import (
|
|
"time"
|
|
|
|
v3 "github.com/coreos/etcd/clientv3"
|
|
|
|
"github.com/shunfei/cronsun"
|
|
"github.com/shunfei/cronsun/conf"
|
|
)
|
|
|
|
type Info struct{}
|
|
|
|
func (inf *Info) Overview(ctx *Context) {
|
|
var overview = struct {
|
|
TotalJobs int64 `json:"totalJobs"`
|
|
JobExecuted *cronsun.StatExecuted `json:"jobExecuted"`
|
|
JobExecutedDaily *cronsun.StatExecuted `json:"jobExecutedDaily"`
|
|
}{}
|
|
|
|
overview.JobExecuted, _ = cronsun.JobLogStat()
|
|
overview.JobExecutedDaily, _ = cronsun.JobLogDayStat(time.Now())
|
|
|
|
gresp, err := cronsun.DefalutClient.Get(conf.Config.Cmd, v3.WithPrefix(), v3.WithCountOnly())
|
|
if err == nil {
|
|
overview.TotalJobs = gresp.Count
|
|
}
|
|
|
|
outJSON(ctx.W, overview)
|
|
}
|