made the preference store GetCategory method sync (#10847)

* made the preference store GetCategory method sync

* fixed the review comments
Этот коммит содержится в:
Pradeep Murugesan
2019-05-15 15:56:42 +01:00
коммит произвёл Christopher Speller
родитель 2130e9f0b1
Коммит 24a02b4168
6 изменённых файлов: 38 добавлений и 31 удалений

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

@@ -180,23 +180,22 @@ func (s SqlPreferenceStore) Get(userId string, category string, name string) (*m
return preference, nil
}
func (s SqlPreferenceStore) GetCategory(userId string, category string) store.StoreChannel {
return store.Do(func(result *store.StoreResult) {
var preferences model.Preferences
func (s SqlPreferenceStore) GetCategory(userId string, category string) (model.Preferences, *model.AppError) {
var preferences model.Preferences
if _, err := s.GetReplica().Select(&preferences,
`SELECT
if _, err := s.GetReplica().Select(&preferences,
`SELECT
*
FROM
Preferences
WHERE
UserId = :UserId
AND Category = :Category`, map[string]interface{}{"UserId": userId, "Category": category}); err != nil {
result.Err = model.NewAppError("SqlPreferenceStore.GetCategory", "store.sql_preference.get_category.app_error", nil, err.Error(), http.StatusInternalServerError)
} else {
result.Data = preferences
}
})
return nil, model.NewAppError("SqlPreferenceStore.GetCategory", "store.sql_preference.get_category.app_error", nil, err.Error(), http.StatusInternalServerError)
}
return preferences, nil
}
func (s SqlPreferenceStore) GetAll(userId string) store.StoreChannel {