[MM-15803] Migrate "Session.AnalyticsSessionCount" to Sync by default (#10948)

* [MM-15803] Migrate "Session.AnalyticsSessionCount" to Sync by default

* Use Explict Async for sessionChan in analytics.go
Этот коммит содержится в:
Bolarinwa Balogun
2019-05-27 12:54:46 -04:00
коммит произвёл Jesús Espino
родитель ff0d3ab00b
Коммит 674b6f2285
5 изменённых файлов: 35 добавлений и 26 удалений

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

@@ -206,21 +206,18 @@ func (me SqlSessionStore) UpdateDeviceId(id string, deviceId string, expiresAt i
})
}
func (me SqlSessionStore) AnalyticsSessionCount() store.StoreChannel {
return store.Do(func(result *store.StoreResult) {
query :=
`SELECT
COUNT(*)
FROM
Sessions
WHERE ExpiresAt > :Time`
if c, err := me.GetReplica().SelectInt(query, map[string]interface{}{"Time": model.GetMillis()}); err != nil {
result.Err = model.NewAppError("SqlSessionStore.AnalyticsSessionCount", "store.sql_session.analytics_session_count.app_error", nil, err.Error(), http.StatusInternalServerError)
} else {
result.Data = c
}
})
func (me SqlSessionStore) AnalyticsSessionCount() (int64, *model.AppError) {
query :=
`SELECT
COUNT(*)
FROM
Sessions
WHERE ExpiresAt > :Time`
count, err := me.GetReplica().SelectInt(query, map[string]interface{}{"Time": model.GetMillis()})
if err != nil {
return int64(0), model.NewAppError("SqlSessionStore.AnalyticsSessionCount", "store.sql_session.analytics_session_count.app_error", nil, err.Error(), http.StatusInternalServerError)
}
return count, nil
}
func (me SqlSessionStore) Cleanup(expiryTime int64, batchSize int64) {