Migrate "User.AnalyticsActiveCount" to Sync by default (#11419)
* migrate User.AnalyticActiveCount to sync default * fixing shadowing variable err * fixing shadowing variable err * run query in async * migrate app/diagnostic to explicit async * remove error logging
Этот коммит содержится в:
коммит произвёл
Jesús Espino
родитель
95652da0b8
Коммит
37b726b651
@@ -8,9 +8,11 @@ import (
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/segmentio/analytics-go"
|
||||
|
||||
"github.com/mattermost/mattermost-server/mlog"
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
analytics "github.com/segmentio/analytics-go"
|
||||
"github.com/mattermost/mattermost-server/store"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -124,10 +126,7 @@ func pluginActivated(pluginStates map[string]*model.PluginState, pluginId string
|
||||
func (a *App) trackActivity() {
|
||||
var userCount int64
|
||||
var botAccountsCount int64
|
||||
var activeUsersDailyCount int64
|
||||
var activeUsersMonthlyCount int64
|
||||
var inactiveUserCount int64
|
||||
var teamCount int64
|
||||
var publicChannelCount int64
|
||||
var privateChannelCount int64
|
||||
var directChannelCount int64
|
||||
@@ -140,16 +139,19 @@ func (a *App) trackActivity() {
|
||||
var incomingWebhooksCount int64
|
||||
var outgoingWebhooksCount int64
|
||||
|
||||
dailyActiveChan := a.Srv.Store.User().AnalyticsActiveCount(DAY_MILLISECONDS)
|
||||
monthlyActiveChan := a.Srv.Store.User().AnalyticsActiveCount(MONTH_MILLISECONDS)
|
||||
activeUsersDailyCountChan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
count, err := a.Srv.Store.User().AnalyticsActiveCount(DAY_MILLISECONDS)
|
||||
activeUsersDailyCountChan <- store.StoreResult{Data: count, Err: err}
|
||||
close(activeUsersDailyCountChan)
|
||||
}()
|
||||
|
||||
if r := <-dailyActiveChan; r.Err == nil {
|
||||
activeUsersDailyCount = r.Data.(int64)
|
||||
}
|
||||
|
||||
if r := <-monthlyActiveChan; r.Err == nil {
|
||||
activeUsersMonthlyCount = r.Data.(int64)
|
||||
}
|
||||
activeUsersMonthlyCountChan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
count, err := a.Srv.Store.User().AnalyticsActiveCount(MONTH_MILLISECONDS)
|
||||
activeUsersMonthlyCountChan <- store.StoreResult{Data: count, Err: err}
|
||||
close(activeUsersMonthlyCountChan)
|
||||
}()
|
||||
|
||||
if count, err := a.Srv.Store.User().Count(model.UserCountOptions{IncludeDeleted: true}); err == nil {
|
||||
userCount = count
|
||||
@@ -212,6 +214,16 @@ func (a *App) trackActivity() {
|
||||
|
||||
outgoingWebhooksCount, _ = a.Srv.Store.Webhook().AnalyticsOutgoingCount("")
|
||||
|
||||
var activeUsersDailyCount int64
|
||||
if r := <-activeUsersDailyCountChan; r.Err == nil {
|
||||
activeUsersDailyCount = r.Data.(int64)
|
||||
}
|
||||
|
||||
var activeUsersMonthlyCount int64
|
||||
if r := <-activeUsersMonthlyCountChan; r.Err == nil {
|
||||
activeUsersMonthlyCount = r.Data.(int64)
|
||||
}
|
||||
|
||||
a.SendDiagnostic(TRACK_ACTIVITY, map[string]interface{}{
|
||||
"registered_users": userCount,
|
||||
"bot_accounts": botAccountsCount,
|
||||
|
||||
Ссылка в новой задаче
Block a user