MM-19957 - Deactivating a user should increment the Daily and… (#13232)
* corrected active count function
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
81cff677b1
Коммит
4e5369e759
@@ -1101,16 +1101,23 @@ func (us SqlUserStore) Count(options model.UserCountOptions) (int64, *model.AppE
|
||||
func (us SqlUserStore) AnalyticsActiveCount(timePeriod int64, options model.UserCountOptions) (int64, *model.AppError) {
|
||||
|
||||
time := model.GetMillis() - timePeriod
|
||||
query := us.getQueryBuilder().Select("COUNT(*)").From("Status AS s").Where("LastActivityAt > :Time", map[string]interface{}{"Time": time})
|
||||
|
||||
query := "SELECT COUNT(*) FROM Status s"
|
||||
|
||||
if options.IncludeBotAccounts {
|
||||
query += " WHERE LastActivityAt > :Time"
|
||||
} else {
|
||||
query += " LEFT JOIN Bots ON s.UserId = Bots.UserId WHERE Bots.UserId IS NULL AND LastActivityAt > :Time"
|
||||
if !options.IncludeBotAccounts {
|
||||
query = query.LeftJoin("Bots ON s.UserId = Bots.UserId").Where("Bots.UserId IS NULL")
|
||||
}
|
||||
|
||||
v, err := us.GetReplica().SelectInt(query, map[string]interface{}{"Time": time})
|
||||
if !options.IncludeDeleted {
|
||||
query = query.LeftJoin("Users ON s.UserId = Users.Id").Where("Users.DeleteAt = 0")
|
||||
}
|
||||
|
||||
queryStr, args, err := query.ToSql()
|
||||
|
||||
if err != nil {
|
||||
return 0, model.NewAppError("SqlUserStore.Get", "store.sql_user.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
v, err := us.GetReplica().SelectInt(queryStr, args...)
|
||||
if err != nil {
|
||||
return 0, model.NewAppError("SqlUserStore.AnalyticsDailyActiveUsers", "store.sql_user.analytics_daily_active_users.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user