* [MM-16173] Migrate Team.AnalyticsTeamCount to Sync by default #11126 + Modified team_store.AnalyticsTeamCount to return (int64, *model.AppError) instead of store.StoreChannel. + Updated the mock store to reflect new return value. + Updated referencing code to handle new sync return value. * Fix shadowing of the err * Fix the empty line between related code * Fix team count call to be an explicit async. * Added error logging to diagnostics.go * Fix gofmt in file
Этот коммит содержится в:
коммит произвёл
Christopher Poile
родитель
e101e1c020
Коммит
b61ded0ae4
@@ -46,7 +46,6 @@ func (a *App) GetAnalytics(name string, teamId string) (model.AnalyticsRows, *mo
|
||||
|
||||
openChan := a.Srv.Store.Channel().AnalyticsTypeCount(teamId, model.CHANNEL_OPEN)
|
||||
privateChan := a.Srv.Store.Channel().AnalyticsTypeCount(teamId, model.CHANNEL_PRIVATE)
|
||||
teamChan := a.Srv.Store.Team().AnalyticsTeamCount()
|
||||
|
||||
var userChan store.StoreChannel
|
||||
var userInactiveChan store.StoreChannel
|
||||
@@ -65,6 +64,12 @@ func (a *App) GetAnalytics(name string, teamId string) (model.AnalyticsRows, *mo
|
||||
|
||||
dailyActiveChan := a.Srv.Store.User().AnalyticsActiveCount(DAY_MILLISECONDS)
|
||||
monthlyActiveChan := a.Srv.Store.User().AnalyticsActiveCount(MONTH_MILLISECONDS)
|
||||
teamCountChan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
teamCount, err := a.Srv.Store.Team().AnalyticsTeamCount()
|
||||
teamCountChan <- store.StoreResult{Data: teamCount, Err: err}
|
||||
close(teamCountChan)
|
||||
}()
|
||||
|
||||
r := <-openChan
|
||||
if r.Err != nil {
|
||||
@@ -108,7 +113,7 @@ func (a *App) GetAnalytics(name string, teamId string) (model.AnalyticsRows, *mo
|
||||
rows[10].Value = float64(r.Data.(int64))
|
||||
}
|
||||
|
||||
r = <-teamChan
|
||||
r = <-teamCountChan
|
||||
if r.Err != nil {
|
||||
return nil, r.Err
|
||||
}
|
||||
|
||||
@@ -166,8 +166,9 @@ func (a *App) trackActivity() {
|
||||
inactiveUserCount = iucr.Data.(int64)
|
||||
}
|
||||
|
||||
if tcr := <-a.Srv.Store.Team().AnalyticsTeamCount(); tcr.Err == nil {
|
||||
teamCount = tcr.Data.(int64)
|
||||
teamCount, err := a.Srv.Store.Team().AnalyticsTeamCount()
|
||||
if err != nil {
|
||||
mlog.Error(err.Error())
|
||||
}
|
||||
|
||||
if ucc := <-a.Srv.Store.Channel().AnalyticsTypeCount("", "O"); ucc.Err == nil {
|
||||
|
||||
@@ -478,13 +478,13 @@ func (me *TestHelper) ResetEmojisMigration() {
|
||||
}
|
||||
|
||||
func (me *TestHelper) CheckTeamCount(t *testing.T, expected int64) {
|
||||
if r := <-me.App.Srv.Store.Team().AnalyticsTeamCount(); r.Err == nil {
|
||||
if r.Data.(int64) != expected {
|
||||
t.Fatalf("Unexpected number of teams. Expected: %v, found: %v", expected, r.Data.(int64))
|
||||
}
|
||||
} else {
|
||||
teamCount, err := me.App.Srv.Store.Team().AnalyticsTeamCount()
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to get team count.")
|
||||
}
|
||||
if teamCount != expected {
|
||||
t.Fatalf("Unexpected number of teams. Expected: %v, found: %v", expected, teamCount)
|
||||
}
|
||||
}
|
||||
|
||||
func (me *TestHelper) CheckChannelsCount(t *testing.T, expected int64) {
|
||||
|
||||
@@ -568,10 +568,8 @@ func TestImportImportTeam(t *testing.T) {
|
||||
scheme2 := th.SetupTeamScheme()
|
||||
|
||||
// Check how many teams are in the database.
|
||||
var teamsCount int64
|
||||
if r := <-th.App.Srv.Store.Team().AnalyticsTeamCount(); r.Err == nil {
|
||||
teamsCount = r.Data.(int64)
|
||||
} else {
|
||||
teamsCount, err := th.App.Srv.Store.Team().AnalyticsTeamCount()
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to get team count.")
|
||||
}
|
||||
|
||||
|
||||
@@ -79,8 +79,8 @@ func (s *Server) DoSecurityUpdateCheck() {
|
||||
v.Set(PROP_SECURITY_ACTIVE_USER_COUNT, strconv.FormatInt(ucr.Data.(int64), 10))
|
||||
}
|
||||
|
||||
if tcr := <-s.Store.Team().AnalyticsTeamCount(); tcr.Err == nil {
|
||||
v.Set(PROP_SECURITY_TEAM_COUNT, strconv.FormatInt(tcr.Data.(int64), 10))
|
||||
if teamCount, err := s.Store.Team().AnalyticsTeamCount(); err == nil {
|
||||
v.Set(PROP_SECURITY_TEAM_COUNT, strconv.FormatInt(teamCount, 10))
|
||||
}
|
||||
|
||||
res, err := http.Get(SECURITY_URL + "/security?" + v.Encode())
|
||||
|
||||
Ссылка в новой задаче
Block a user