MM-21898 - Part 1: Generate and use an interface instead of *A… (#13840)
* Generate and use an interface instead of *App
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
66fc096768
Коммит
17523fa5d9
@@ -67,7 +67,7 @@ func (a *App) SendDailyDiagnostics() {
|
||||
|
||||
func (a *App) sendDailyDiagnostics(override bool) {
|
||||
if *a.Config().LogSettings.EnableDiagnostics && a.IsLeader() && (!strings.Contains(SEGMENT_KEY, "placeholder") || override) {
|
||||
a.Srv.initDiagnostics("")
|
||||
a.Srv().initDiagnostics("")
|
||||
a.trackActivity()
|
||||
a.trackConfig()
|
||||
a.trackLicense()
|
||||
@@ -80,7 +80,7 @@ func (a *App) sendDailyDiagnostics(override bool) {
|
||||
}
|
||||
|
||||
func (a *App) SendDiagnostic(event string, properties map[string]interface{}) {
|
||||
a.Srv.diagnosticClient.Enqueue(analytics.Track{
|
||||
a.Srv().diagnosticClient.Enqueue(analytics.Track{
|
||||
Event: event,
|
||||
UserId: a.DiagnosticId(),
|
||||
Properties: properties,
|
||||
@@ -137,78 +137,78 @@ func (a *App) trackActivity() {
|
||||
|
||||
activeUsersDailyCountChan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
count, err := a.Srv.Store.User().AnalyticsActiveCount(DAY_MILLISECONDS, model.UserCountOptions{IncludeBotAccounts: false, IncludeDeleted: false})
|
||||
count, err := a.Srv().Store.User().AnalyticsActiveCount(DAY_MILLISECONDS, model.UserCountOptions{IncludeBotAccounts: false, IncludeDeleted: false})
|
||||
activeUsersDailyCountChan <- store.StoreResult{Data: count, Err: err}
|
||||
close(activeUsersDailyCountChan)
|
||||
}()
|
||||
|
||||
activeUsersMonthlyCountChan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
count, err := a.Srv.Store.User().AnalyticsActiveCount(MONTH_MILLISECONDS, model.UserCountOptions{IncludeBotAccounts: false, IncludeDeleted: false})
|
||||
count, err := a.Srv().Store.User().AnalyticsActiveCount(MONTH_MILLISECONDS, model.UserCountOptions{IncludeBotAccounts: false, IncludeDeleted: false})
|
||||
activeUsersMonthlyCountChan <- store.StoreResult{Data: count, Err: err}
|
||||
close(activeUsersMonthlyCountChan)
|
||||
}()
|
||||
|
||||
if count, err := a.Srv.Store.User().Count(model.UserCountOptions{IncludeDeleted: true}); err == nil {
|
||||
if count, err := a.Srv().Store.User().Count(model.UserCountOptions{IncludeDeleted: true}); err == nil {
|
||||
userCount = count
|
||||
}
|
||||
|
||||
if count, err := a.Srv.Store.User().Count(model.UserCountOptions{IncludeBotAccounts: true, ExcludeRegularUsers: true}); err == nil {
|
||||
if count, err := a.Srv().Store.User().Count(model.UserCountOptions{IncludeBotAccounts: true, ExcludeRegularUsers: true}); err == nil {
|
||||
botAccountsCount = count
|
||||
}
|
||||
|
||||
if iucr, err := a.Srv.Store.User().AnalyticsGetInactiveUsersCount(); err == nil {
|
||||
if iucr, err := a.Srv().Store.User().AnalyticsGetInactiveUsersCount(); err == nil {
|
||||
inactiveUserCount = iucr
|
||||
}
|
||||
|
||||
teamCount, err := a.Srv.Store.Team().AnalyticsTeamCount(false)
|
||||
teamCount, err := a.Srv().Store.Team().AnalyticsTeamCount(false)
|
||||
if err != nil {
|
||||
mlog.Error(err.Error())
|
||||
}
|
||||
|
||||
if ucc, err := a.Srv.Store.Channel().AnalyticsTypeCount("", "O"); err == nil {
|
||||
if ucc, err := a.Srv().Store.Channel().AnalyticsTypeCount("", "O"); err == nil {
|
||||
publicChannelCount = ucc
|
||||
}
|
||||
|
||||
if pcc, err := a.Srv.Store.Channel().AnalyticsTypeCount("", "P"); err == nil {
|
||||
if pcc, err := a.Srv().Store.Channel().AnalyticsTypeCount("", "P"); err == nil {
|
||||
privateChannelCount = pcc
|
||||
}
|
||||
|
||||
if dcc, err := a.Srv.Store.Channel().AnalyticsTypeCount("", "D"); err == nil {
|
||||
if dcc, err := a.Srv().Store.Channel().AnalyticsTypeCount("", "D"); err == nil {
|
||||
directChannelCount = dcc
|
||||
}
|
||||
|
||||
if duccr, err := a.Srv.Store.Channel().AnalyticsDeletedTypeCount("", "O"); err == nil {
|
||||
if duccr, err := a.Srv().Store.Channel().AnalyticsDeletedTypeCount("", "O"); err == nil {
|
||||
deletedPublicChannelCount = duccr
|
||||
}
|
||||
|
||||
if dpccr, err := a.Srv.Store.Channel().AnalyticsDeletedTypeCount("", "P"); err == nil {
|
||||
if dpccr, err := a.Srv().Store.Channel().AnalyticsDeletedTypeCount("", "P"); err == nil {
|
||||
deletedPrivateChannelCount = dpccr
|
||||
}
|
||||
|
||||
postsCount, _ = a.Srv.Store.Post().AnalyticsPostCount("", false, false)
|
||||
postsCount, _ = a.Srv().Store.Post().AnalyticsPostCount("", false, false)
|
||||
|
||||
postCountsOptions := &model.AnalyticsPostCountsOptions{TeamId: "", BotsOnly: false, YesterdayOnly: true}
|
||||
postCountsYesterday, _ := a.Srv.Store.Post().AnalyticsPostCountsByDay(postCountsOptions)
|
||||
postCountsYesterday, _ := a.Srv().Store.Post().AnalyticsPostCountsByDay(postCountsOptions)
|
||||
postsCountPreviousDay = 0
|
||||
if len(postCountsYesterday) > 0 {
|
||||
postsCountPreviousDay = int64(postCountsYesterday[0].Value)
|
||||
}
|
||||
|
||||
postCountsOptions = &model.AnalyticsPostCountsOptions{TeamId: "", BotsOnly: true, YesterdayOnly: true}
|
||||
botPostCountsYesterday, _ := a.Srv.Store.Post().AnalyticsPostCountsByDay(postCountsOptions)
|
||||
botPostCountsYesterday, _ := a.Srv().Store.Post().AnalyticsPostCountsByDay(postCountsOptions)
|
||||
botPostsCountPreviousDay = 0
|
||||
if len(botPostCountsYesterday) > 0 {
|
||||
botPostsCountPreviousDay = int64(botPostCountsYesterday[0].Value)
|
||||
}
|
||||
|
||||
slashCommandsCount, _ = a.Srv.Store.Command().AnalyticsCommandCount("")
|
||||
slashCommandsCount, _ = a.Srv().Store.Command().AnalyticsCommandCount("")
|
||||
|
||||
if c, err := a.Srv.Store.Webhook().AnalyticsIncomingCount(""); err == nil {
|
||||
if c, err := a.Srv().Store.Webhook().AnalyticsIncomingCount(""); err == nil {
|
||||
incomingWebhooksCount = c
|
||||
}
|
||||
|
||||
outgoingWebhooksCount, _ = a.Srv.Store.Webhook().AnalyticsOutgoingCount("")
|
||||
outgoingWebhooksCount, _ = a.Srv().Store.Webhook().AnalyticsOutgoingCount("")
|
||||
|
||||
var activeUsersDailyCount int64
|
||||
if r := <-activeUsersDailyCountChan; r.Err == nil {
|
||||
@@ -788,7 +788,7 @@ func (a *App) trackServer() {
|
||||
"operating_system": runtime.GOOS,
|
||||
}
|
||||
|
||||
if scr, err := a.Srv.Store.User().AnalyticsGetSystemAdminCount(); err == nil {
|
||||
if scr, err := a.Srv().Store.User().AnalyticsGetSystemAdminCount(); err == nil {
|
||||
data["system_admins"] = scr
|
||||
}
|
||||
|
||||
@@ -797,12 +797,12 @@ func (a *App) trackServer() {
|
||||
|
||||
func (a *App) trackPermissions() {
|
||||
phase1Complete := false
|
||||
if _, err := a.Srv.Store.System().GetByName(ADVANCED_PERMISSIONS_MIGRATION_KEY); err == nil {
|
||||
if _, err := a.Srv().Store.System().GetByName(ADVANCED_PERMISSIONS_MIGRATION_KEY); err == nil {
|
||||
phase1Complete = true
|
||||
}
|
||||
|
||||
phase2Complete := false
|
||||
if _, err := a.Srv.Store.System().GetByName(model.MIGRATION_KEY_ADVANCED_PERMISSIONS_PHASE_2); err == nil {
|
||||
if _, err := a.Srv().Store.System().GetByName(model.MIGRATION_KEY_ADVANCED_PERMISSIONS_PHASE_2); err == nil {
|
||||
phase2Complete = true
|
||||
}
|
||||
|
||||
@@ -894,7 +894,7 @@ func (a *App) trackPermissions() {
|
||||
channelGuestPermissions = strings.Join(role.Permissions, " ")
|
||||
}
|
||||
|
||||
count, _ := a.Srv.Store.Team().AnalyticsGetTeamCountForScheme(scheme.Id)
|
||||
count, _ := a.Srv().Store.Team().AnalyticsGetTeamCountForScheme(scheme.Id)
|
||||
|
||||
a.SendDiagnostic(TRACK_PERMISSIONS_TEAM_SCHEMES, map[string]interface{}{
|
||||
"scheme_id": scheme.Id,
|
||||
@@ -913,45 +913,45 @@ func (a *App) trackPermissions() {
|
||||
func (a *App) trackElasticsearch() {
|
||||
data := map[string]interface{}{}
|
||||
|
||||
if a.Elasticsearch != nil && a.Elasticsearch.GetVersion() != 0 {
|
||||
data["elasticsearch_server_version"] = a.Elasticsearch.GetVersion()
|
||||
if a.Elasticsearch() != nil && a.Elasticsearch().GetVersion() != 0 {
|
||||
data["elasticsearch_server_version"] = a.Elasticsearch().GetVersion()
|
||||
}
|
||||
|
||||
a.SendDiagnostic(TRACK_ELASTICSEARCH, data)
|
||||
}
|
||||
|
||||
func (a *App) trackGroups() {
|
||||
groupCount, err := a.Srv.Store.Group().GroupCount()
|
||||
groupCount, err := a.Srv().Store.Group().GroupCount()
|
||||
if err != nil {
|
||||
mlog.Error(err.Error())
|
||||
}
|
||||
|
||||
groupTeamCount, err := a.Srv.Store.Group().GroupTeamCount()
|
||||
groupTeamCount, err := a.Srv().Store.Group().GroupTeamCount()
|
||||
if err != nil {
|
||||
mlog.Error(err.Error())
|
||||
}
|
||||
|
||||
groupChannelCount, err := a.Srv.Store.Group().GroupChannelCount()
|
||||
groupChannelCount, err := a.Srv().Store.Group().GroupChannelCount()
|
||||
if err != nil {
|
||||
mlog.Error(err.Error())
|
||||
}
|
||||
|
||||
groupSyncedTeamCount, err := a.Srv.Store.Team().GroupSyncedTeamCount()
|
||||
groupSyncedTeamCount, err := a.Srv().Store.Team().GroupSyncedTeamCount()
|
||||
if err != nil {
|
||||
mlog.Error(err.Error())
|
||||
}
|
||||
|
||||
groupSyncedChannelCount, err := a.Srv.Store.Channel().GroupSyncedChannelCount()
|
||||
groupSyncedChannelCount, err := a.Srv().Store.Channel().GroupSyncedChannelCount()
|
||||
if err != nil {
|
||||
mlog.Error(err.Error())
|
||||
}
|
||||
|
||||
groupMemberCount, err := a.Srv.Store.Group().GroupMemberCount()
|
||||
groupMemberCount, err := a.Srv().Store.Group().GroupMemberCount()
|
||||
if err != nil {
|
||||
mlog.Error(err.Error())
|
||||
}
|
||||
|
||||
distinctGroupMemberCount, err := a.Srv.Store.Group().DistinctGroupMemberCount()
|
||||
distinctGroupMemberCount, err := a.Srv().Store.Group().DistinctGroupMemberCount()
|
||||
if err != nil {
|
||||
mlog.Error(err.Error())
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user