collect target total number

This commit is contained in:
Ulric Qin 2022-08-17 20:16:42 +08:00
parent b4ddd03691
commit 388228a631
2 changed files with 12 additions and 4 deletions

View File

@ -116,6 +116,10 @@ func buildTargetWhere(bgid int64, clusters []string, query string) *gorm.DB {
return session
}
func TargetTotalCount() (int64, error) {
return Count(DB().Model(new(Target)))
}
func TargetTotal(bgid int64, clusters []string, query string) (int64, error) {
return Count(buildTargetWhere(bgid, clusters, query))
}

View File

@ -59,14 +59,18 @@ func Report() {
}
func report() {
sps, _ := getSamples()
// sps, _ := getSamples()
tnum, err := models.TargetTotalCount()
if err != nil {
return
}
hostname, err := os.Hostname()
if err != nil {
return
}
num, err := models.UserTotal("")
unum, err := models.UserTotal("")
if err != nil {
return
}
@ -74,8 +78,8 @@ func report() {
maintainer := "blank"
u := Usage{
Samples: sps,
Users: float64(num),
Samples: float64(tnum),
Users: float64(unum),
Hostname: hostname,
Maintainer: maintainer,
Version: version.VERSION,