Add AWS Metering service support (#15290)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
50e37068b5
Коммит
1c0d590c81
@@ -13,6 +13,7 @@ import (
|
||||
|
||||
sq "github.com/Masterminds/squirrel"
|
||||
"github.com/mattermost/gorp"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v5/einterfaces"
|
||||
"github.com/mattermost/mattermost-server/v5/model"
|
||||
@@ -1267,7 +1268,31 @@ func (us SqlUserStore) AnalyticsActiveCount(timePeriod int64, options model.User
|
||||
|
||||
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)
|
||||
return 0, model.NewAppError("SqlUserStore.AnalyticsActiveCount", "store.sql_user.analytics_daily_active_users.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
func (us SqlUserStore) AnalyticsActiveCountForPeriod(startTime int64, endTime int64, options model.UserCountOptions) (int64, error) {
|
||||
query := us.getQueryBuilder().Select("COUNT(*)").From("Status AS s").Where("LastActivityAt > :StartTime AND LastActivityAt <= :EndTime", map[string]interface{}{"StartTime": startTime, "EndTime": endTime})
|
||||
|
||||
if !options.IncludeBotAccounts {
|
||||
query = query.LeftJoin("Bots ON s.UserId = Bots.UserId").Where("Bots.UserId IS NULL")
|
||||
}
|
||||
|
||||
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, errors.Wrap(err, "Failed to build query.")
|
||||
}
|
||||
|
||||
v, err := us.GetReplica().SelectInt(queryStr, args...)
|
||||
if err != nil {
|
||||
return 0, errors.Wrap(err, "Unable to get the active users during the requested period.")
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user