* modify Get method in preference_store * modify interface to match changes on preference store Get method * modify variable initialization * fix behavior on GetPreferenceByCategoryAndNameForUser
Этот коммит содержится в:
коммит произвёл
Miguel de la Cruz
родитель
b3e09715df
Коммит
a68ad55151
@@ -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 {
|
||||
|
||||
Ссылка в новой задаче
Block a user