From 09ffe4001131fe99d4b176e04022403f6755141c Mon Sep 17 00:00:00 2001 From: withchao <993506633@qq.com> Date: Mon, 3 Jul 2023 12:11:09 +0800 Subject: [PATCH] statistics user register --- pkg/common/db/relation/user_model.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/common/db/relation/user_model.go b/pkg/common/db/relation/user_model.go index 385e65809..3390f7d3b 100644 --- a/pkg/common/db/relation/user_model.go +++ b/pkg/common/db/relation/user_model.go @@ -74,8 +74,8 @@ func (u *UserGorm) CountTotal(ctx context.Context) (count int64, err error) { func (u *UserGorm) CountRangeEverydayTotal(ctx context.Context, start time.Time, end time.Time) (map[string]int64, error) { var res []struct { - Date string `gorm:"column:date"` - Count int64 `gorm:"column:count"` + Date time.Time `gorm:"column:date"` + Count int64 `gorm:"column:count"` } err := u.db(ctx).Model(&relation.UserModel{}).Select("DATE(create_time) AS date, count(1) AS count").Where("create_time >= ? and create_time < ?", start, end).Group("date").Find(&res).Error if err != nil { @@ -83,7 +83,7 @@ func (u *UserGorm) CountRangeEverydayTotal(ctx context.Context, start time.Time, } v := make(map[string]int64) for _, r := range res { - v[r.Date] = r.Count + v[r.Date.Format("2006-01-02")] = r.Count } return v, nil }