[MM-16353] Migrate Channel.AnalyticsDeletedTypeCount to Sync by default (#11289)

* [MM-16353] Migrate AnalyticsDeletedTypeCount to Sync by default

* refactor: decrease branching

* test: use testify for assertion
Этот коммит содержится в:
krjn
2019-06-19 15:23:16 +00:00
коммит произвёл Jesús Espino
родитель 73a1bb80f1
Коммит a39ceadd58
5 изменённых файлов: 46 добавлений и 55 удалений

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

@@ -1886,22 +1886,19 @@ func (s SqlChannelStore) AnalyticsTypeCount(teamId string, channelType string) (
return value, nil
}
func (s SqlChannelStore) AnalyticsDeletedTypeCount(teamId string, channelType string) store.StoreChannel {
return store.Do(func(result *store.StoreResult) {
query := "SELECT COUNT(Id) AS Value FROM Channels WHERE Type = :ChannelType AND DeleteAt > 0"
func (s SqlChannelStore) AnalyticsDeletedTypeCount(teamId string, channelType string) (int64, *model.AppError) {
query := "SELECT COUNT(Id) AS Value FROM Channels WHERE Type = :ChannelType AND DeleteAt > 0"
if len(teamId) > 0 {
query += " AND TeamId = :TeamId"
}
if len(teamId) > 0 {
query += " AND TeamId = :TeamId"
}
v, err := s.GetReplica().SelectInt(query, map[string]interface{}{"TeamId": teamId, "ChannelType": channelType})
if err != nil {
result.Err = model.NewAppError("SqlChannelStore.AnalyticsDeletedTypeCount", "store.sql_channel.analytics_deleted_type_count.app_error", nil, err.Error(), http.StatusInternalServerError)
return
}
v, err := s.GetReplica().SelectInt(query, map[string]interface{}{"TeamId": teamId, "ChannelType": channelType})
if err != nil {
return 0, model.NewAppError("SqlChannelStore.AnalyticsDeletedTypeCount", "store.sql_channel.analytics_deleted_type_count.app_error", nil, err.Error(), http.StatusInternalServerError)
}
result.Data = v
})
return v, nil
}
func (s SqlChannelStore) GetMembersForUser(teamId string, userId string) store.StoreChannel {