* statistics user register

* refactor: router change

* minio init

---------

Co-authored-by: withchao <993506633@qq.com>
Co-authored-by: Gordon <1432970085@qq.com>
This commit is contained in:
WangchuXiao
2023-07-03 15:21:17 +08:00
committed by GitHub
parent e50b8bd8f1
commit 941c1f954e
3 changed files with 32 additions and 25 deletions
+3 -3
View File
@@ -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
}