[MM-15297] Migrate "Preference.Get" to Sync by default #10721 (#10811)

* modify Get method in preference_store

* modify interface to match changes on preference store Get method

* modify variable initialization

* fix behavior on GetPreferenceByCategoryAndNameForUser
Этот коммит содержится в:
Ivana Irene Thomas
2019-05-15 19:20:26 +07:00
коммит произвёл Miguel de la Cruz
родитель b3e09715df
Коммит a68ad55151
8 изменённых файлов: 56 добавлений и 52 удалений

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

@@ -163,24 +163,21 @@ func (s SqlPreferenceStore) update(transaction *gorp.Transaction, preference *mo
return result
}
func (s SqlPreferenceStore) Get(userId string, category string, name string) store.StoreChannel {
return store.Do(func(result *store.StoreResult) {
var preference model.Preference
func (s SqlPreferenceStore) Get(userId string, category string, name string) (*model.Preference, *model.AppError) {
var preference *model.Preference
if err := s.GetReplica().SelectOne(&preference,
`SELECT
*
FROM
Preferences
WHERE
UserId = :UserId
AND Category = :Category
AND Name = :Name`, map[string]interface{}{"UserId": userId, "Category": category, "Name": name}); err != nil {
result.Err = model.NewAppError("SqlPreferenceStore.Get", "store.sql_preference.get.app_error", nil, err.Error(), http.StatusInternalServerError)
} else {
result.Data = preference
}
})
if err := s.GetReplica().SelectOne(&preference,
`SELECT
*
FROM
Preferences
WHERE
UserId = :UserId
AND Category = :Category
AND Name = :Name`, map[string]interface{}{"UserId": userId, "Category": category, "Name": name}); err != nil {
return nil, model.NewAppError("SqlPreferenceStore.Get", "store.sql_preference.get.app_error", nil, err.Error(), http.StatusInternalServerError)
}
return preference, nil
}
func (s SqlPreferenceStore) GetCategory(userId string, category string) store.StoreChannel {