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.
cronsun/web/info.go

31 lines
714 B

8 years ago
package web
import (
"time"
v3 "github.com/coreos/etcd/clientv3"
"github.com/shunfei/cronsun"
"github.com/shunfei/cronsun/conf"
8 years ago
)
type Info struct{}
func (inf *Info) Overview(ctx *Context) {
8 years ago
var overview = struct {
TotalJobs int64 `json:"totalJobs"`
JobExecuted *cronsun.StatExecuted `json:"jobExecuted"`
JobExecutedDaily *cronsun.StatExecuted `json:"jobExecutedDaily"`
8 years ago
}{}
overview.JobExecuted, _ = cronsun.JobLogStat()
overview.JobExecutedDaily, _ = cronsun.JobLogDayStat(time.Now())
8 years ago
gresp, err := cronsun.DefalutClient.Get(conf.Config.Cmd, v3.WithPrefix(), v3.WithCountOnly())
8 years ago
if err == nil {
overview.TotalJobs = gresp.Count
}
outJSON(ctx.W, overview)
8 years ago
}