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
Этот коммит содержится в:
Adzim Zul Fahmi
2019-07-03 18:16:27 +07:00
коммит произвёл Jesús Espino
родитель 95652da0b8
Коммит 37b726b651
5 изменённых файлов: 63 добавлений и 34 удалений

Просмотреть файл

@@ -66,7 +66,7 @@ func (a *App) GetAnalytics(name string, teamId string) (model.AnalyticsRows, *mo
close(userInactiveChan)
}()
} else {
userChan := make(chan store.StoreResult, 1)
userChan = make(chan store.StoreResult, 1)
go func() {
count, err := a.Srv.Store.User().Count(model.UserCountOptions{TeamId: teamId})
userChan <- store.StoreResult{Data: count, Err: err}
@@ -84,8 +84,6 @@ 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()
@@ -93,6 +91,20 @@ func (a *App) GetAnalytics(name string, teamId string) (model.AnalyticsRows, *mo
close(teamCountChan)
}()
dailyActiveChan := make(chan store.StoreResult, 1)
go func() {
dailyActive, err := a.Srv.Store.User().AnalyticsActiveCount(DAY_MILLISECONDS)
dailyActiveChan <- store.StoreResult{Data: dailyActive, Err: err}
close(dailyActiveChan)
}()
monthlyActiveChan := make(chan store.StoreResult, 1)
go func() {
monthlyActive, err := a.Srv.Store.User().AnalyticsActiveCount(MONTH_MILLISECONDS)
monthlyActiveChan <- store.StoreResult{Data: monthlyActive, Err: err}
close(monthlyActiveChan)
}()
r := <-openChan
if r.Err != nil {
return nil, r.Err