2017-02-20 09:57:22 +00:00
|
|
|
package web
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
v3 "github.com/coreos/etcd/clientv3"
|
|
|
|
|
2017-05-09 10:27:32 +00:00
|
|
|
"github.com/shunfei/cronsun/conf"
|
|
|
|
"github.com/shunfei/cronsun/models"
|
2017-02-20 09:57:22 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type Info struct{}
|
|
|
|
|
|
|
|
func (inf *Info) Overview(w http.ResponseWriter, r *http.Request) {
|
|
|
|
var overview = struct {
|
|
|
|
TotalJobs int64 `json:"totalJobs"`
|
|
|
|
JobExecuted *models.StatExecuted `json:"jobExecuted"`
|
|
|
|
JobExecutedDaily *models.StatExecuted `json:"jobExecutedDaily"`
|
|
|
|
}{}
|
|
|
|
|
|
|
|
overview.JobExecuted, _ = models.JobLogStat()
|
|
|
|
overview.JobExecutedDaily, _ = models.JobLogDayStat(time.Now())
|
|
|
|
|
|
|
|
gresp, err := models.DefalutClient.Get(conf.Config.Cmd, v3.WithPrefix(), v3.WithCountOnly())
|
|
|
|
if err == nil {
|
|
|
|
overview.TotalJobs = gresp.Count
|
|
|
|
}
|
|
|
|
|
|
|
|
outJSON(w, overview)
|
|
|
|
}
|