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 return session
} }
func TargetTotalCount() (int64, error) {
return Count(DB().Model(new(Target)))
}
func TargetTotal(bgid int64, clusters []string, query string) (int64, error) { func TargetTotal(bgid int64, clusters []string, query string) (int64, error) {
return Count(buildTargetWhere(bgid, clusters, query)) return Count(buildTargetWhere(bgid, clusters, query))
} }

View File

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