mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-05 09:36:00 +08:00
UserRegisterCount
This commit is contained in:
@@ -31,7 +31,7 @@ type UserDatabase interface {
|
||||
//函数内部先查询db中是否存在,存在则什么都不做;不存在则插入
|
||||
InitOnce(ctx context.Context, users []*relation.UserModel) (err error)
|
||||
// 获取用户总数
|
||||
CountTotal(ctx context.Context) (int64, error)
|
||||
CountTotal(ctx context.Context, before *time.Time) (int64, error)
|
||||
// 获取范围内用户增量
|
||||
CountRangeEverydayTotal(ctx context.Context, start time.Time, end time.Time) (map[string]int64, error)
|
||||
}
|
||||
@@ -134,8 +134,8 @@ func (u *userDatabase) GetAllUserID(ctx context.Context) (userIDs []string, err
|
||||
return u.userDB.GetAllUserID(ctx)
|
||||
}
|
||||
|
||||
func (u *userDatabase) CountTotal(ctx context.Context) (count int64, err error) {
|
||||
return u.userDB.CountTotal(ctx)
|
||||
func (u *userDatabase) CountTotal(ctx context.Context, before *time.Time) (count int64, err error) {
|
||||
return u.userDB.CountTotal(ctx, before)
|
||||
}
|
||||
|
||||
func (u *userDatabase) CountRangeEverydayTotal(ctx context.Context, start time.Time, end time.Time) (map[string]int64, error) {
|
||||
|
||||
@@ -67,9 +67,15 @@ func (u *UserGorm) GetUserGlobalRecvMsgOpt(ctx context.Context, userID string) (
|
||||
return opt, err
|
||||
}
|
||||
|
||||
func (u *UserGorm) CountTotal(ctx context.Context) (count int64, err error) {
|
||||
err = u.db(ctx).Model(&relation.UserModel{}).Count(&count).Error
|
||||
return count, errs.Wrap(err)
|
||||
func (u *UserGorm) CountTotal(ctx context.Context, before *time.Time) (count int64, err error) {
|
||||
db := u.db(ctx).Model(&relation.UserModel{})
|
||||
if before != nil {
|
||||
db = db.Where("create_time < ?", before)
|
||||
}
|
||||
if err := db.Count(&count).Error; err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return count, nil
|
||||
}
|
||||
|
||||
func (u *UserGorm) CountRangeEverydayTotal(ctx context.Context, start time.Time, end time.Time) (map[string]int64, error) {
|
||||
|
||||
@@ -52,7 +52,7 @@ type UserModelInterface interface {
|
||||
GetAllUserID(ctx context.Context) (userIDs []string, err error)
|
||||
GetUserGlobalRecvMsgOpt(ctx context.Context, userID string) (opt int, err error)
|
||||
// 获取用户总数
|
||||
CountTotal(ctx context.Context) (count int64, err error)
|
||||
CountTotal(ctx context.Context, before *time.Time) (count int64, err error)
|
||||
// 获取范围内用户增量
|
||||
CountRangeEverydayTotal(ctx context.Context, start time.Time, end time.Time) (map[string]int64, error)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user