MM-15291: migrate commandStore.Delete to sync by default (#10742)

Этот коммит содержится в:
Puneeth Reddy
2019-05-01 00:10:27 -07:00
коммит произвёл Hanzei
родитель e6be06b3fc
Коммит ebbfdf9e5c
5 изменённых файлов: 20 добавлений и 20 удалений

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

@@ -525,9 +525,6 @@ func (a *App) DeleteCommand(commandId string) *model.AppError {
if !*a.Config().ServiceSettings.EnableCommands { if !*a.Config().ServiceSettings.EnableCommands {
return model.NewAppError("DeleteCommand", "api.command.disabled.app_error", nil, "", http.StatusNotImplemented) return model.NewAppError("DeleteCommand", "api.command.disabled.app_error", nil, "", http.StatusNotImplemented)
} }
result := <-a.Srv.Store.Command().Delete(commandId, model.GetMillis())
if result.Err != nil { return a.Srv.Store.Command().Delete(commandId, model.GetMillis())
return result.Err
}
return nil
} }

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

@@ -102,13 +102,13 @@ func (s SqlCommandStore) GetByTrigger(teamId string, trigger string) store.Store
}) })
} }
func (s SqlCommandStore) Delete(commandId string, time int64) store.StoreChannel { func (s SqlCommandStore) Delete(commandId string, time int64) *model.AppError {
return store.Do(func(result *store.StoreResult) { _, err := s.GetMaster().Exec("Update Commands SET DeleteAt = :DeleteAt, UpdateAt = :UpdateAt WHERE Id = :Id", map[string]interface{}{"DeleteAt": time, "UpdateAt": time, "Id": commandId})
_, err := s.GetMaster().Exec("Update Commands SET DeleteAt = :DeleteAt, UpdateAt = :UpdateAt WHERE Id = :Id", map[string]interface{}{"DeleteAt": time, "UpdateAt": time, "Id": commandId}) if err != nil {
if err != nil { return model.NewAppError("SqlCommandStore.Delete", "store.sql_command.save.delete.app_error", nil, "id="+commandId+", err="+err.Error(), http.StatusInternalServerError)
result.Err = model.NewAppError("SqlCommandStore.Delete", "store.sql_command.save.delete.app_error", nil, "id="+commandId+", err="+err.Error(), http.StatusInternalServerError) }
}
}) return nil
} }
func (s SqlCommandStore) PermanentDeleteByTeam(teamId string) *model.AppError { func (s SqlCommandStore) PermanentDeleteByTeam(teamId string) *model.AppError {

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

@@ -414,7 +414,7 @@ type CommandStore interface {
Get(id string) StoreChannel Get(id string) StoreChannel
GetByTeam(teamId string) ([]*model.Command, *model.AppError) GetByTeam(teamId string) ([]*model.Command, *model.AppError)
GetByTrigger(teamId string, trigger string) StoreChannel GetByTrigger(teamId string, trigger string) StoreChannel
Delete(commandId string, time int64) StoreChannel Delete(commandId string, time int64) *model.AppError
PermanentDeleteByTeam(teamId string) *model.AppError PermanentDeleteByTeam(teamId string) *model.AppError
PermanentDeleteByUser(userId string) *model.AppError PermanentDeleteByUser(userId string) *model.AppError
Update(hook *model.Command) (*model.Command, *model.AppError) Update(hook *model.Command) (*model.Command, *model.AppError)

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

@@ -127,7 +127,10 @@ func testCommandStoreGetByTrigger(t *testing.T, ss store.Store) {
} }
} }
store.Must(ss.Command().Delete(o1.Id, model.GetMillis())) err = ss.Command().Delete(o1.Id, model.GetMillis())
if err != nil {
t.Fatal(err)
}
if result := <-ss.Command().GetByTrigger(o1.TeamId, o1.Trigger); result.Err == nil { if result := <-ss.Command().GetByTrigger(o1.TeamId, o1.Trigger); result.Err == nil {
t.Fatal("no commands should have returned") t.Fatal("no commands should have returned")
@@ -155,8 +158,8 @@ func testCommandStoreDelete(t *testing.T, ss store.Store) {
} }
} }
if r2 := <-ss.Command().Delete(o1.Id, model.GetMillis()); r2.Err != nil { if err := ss.Command().Delete(o1.Id, model.GetMillis()); err != nil {
t.Fatal(r2.Err) t.Fatal(err)
} }
if r3 := (<-ss.Command().Get(o1.Id)); r3.Err == nil { if r3 := (<-ss.Command().Get(o1.Id)); r3.Err == nil {

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

@@ -37,15 +37,15 @@ func (_m *CommandStore) AnalyticsCommandCount(teamId string) (int64, *model.AppE
} }
// Delete provides a mock function with given fields: commandId, time // Delete provides a mock function with given fields: commandId, time
func (_m *CommandStore) Delete(commandId string, time int64) store.StoreChannel { func (_m *CommandStore) Delete(commandId string, time int64) *model.AppError {
ret := _m.Called(commandId, time) ret := _m.Called(commandId, time)
var r0 store.StoreChannel var r0 *model.AppError
if rf, ok := ret.Get(0).(func(string, int64) store.StoreChannel); ok { if rf, ok := ret.Get(0).(func(string, int64) *model.AppError); ok {
r0 = rf(commandId, time) r0 = rf(commandId, time)
} else { } else {
if ret.Get(0) != nil { if ret.Get(0) != nil {
r0 = ret.Get(0).(store.StoreChannel) r0 = ret.Get(0).(*model.AppError)
} }
} }