MM-15292: migrate commandstore.PermanentDeleteByTeam to sync by default (#10743)

Этот коммит содержится в:
Puneeth Reddy
2019-04-30 02:10:08 -07:00
коммит произвёл Hanzei
родитель 503b26a904
Коммит d59843725f
5 изменённых файлов: 15 добавлений и 16 удалений

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

@@ -1105,8 +1105,8 @@ func (a *App) PermanentDeleteTeam(team *model.Team) *model.AppError {
return result.Err return result.Err
} }
if result := <-a.Srv.Store.Command().PermanentDeleteByTeam(team.Id); result.Err != nil { if err := a.Srv.Store.Command().PermanentDeleteByTeam(team.Id); err != nil {
return result.Err return err
} }
if result := <-a.Srv.Store.Team().PermanentDelete(team.Id); result.Err != nil { if result := <-a.Srv.Store.Team().PermanentDelete(team.Id); result.Err != nil {

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

@@ -111,13 +111,12 @@ func (s SqlCommandStore) Delete(commandId string, time int64) store.StoreChannel
}) })
} }
func (s SqlCommandStore) PermanentDeleteByTeam(teamId string) store.StoreChannel { func (s SqlCommandStore) PermanentDeleteByTeam(teamId string) *model.AppError {
return store.Do(func(result *store.StoreResult) { _, err := s.GetMaster().Exec("DELETE FROM Commands WHERE TeamId = :TeamId", map[string]interface{}{"TeamId": teamId})
_, err := s.GetMaster().Exec("DELETE FROM Commands WHERE TeamId = :TeamId", map[string]interface{}{"TeamId": teamId}) if err != nil {
if err != nil { return model.NewAppError("SqlCommandStore.DeleteByTeam", "store.sql_command.save.delete_perm.app_error", nil, "id="+teamId+", err="+err.Error(), http.StatusInternalServerError)
result.Err = model.NewAppError("SqlCommandStore.DeleteByTeam", "store.sql_command.save.delete_perm.app_error", nil, "id="+teamId+", err="+err.Error(), http.StatusInternalServerError) }
} return nil
})
} }
func (s SqlCommandStore) PermanentDeleteByUser(userId string) *model.AppError { func (s SqlCommandStore) PermanentDeleteByUser(userId string) *model.AppError {

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

@@ -414,7 +414,7 @@ type CommandStore interface {
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) StoreChannel
PermanentDeleteByTeam(teamId string) StoreChannel 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)
AnalyticsCommandCount(teamId string) StoreChannel AnalyticsCommandCount(teamId string) StoreChannel

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

@@ -186,8 +186,8 @@ func testCommandStoreDeleteByTeam(t *testing.T, ss store.Store) {
} }
} }
if r2 := <-ss.Command().PermanentDeleteByTeam(o1.TeamId); r2.Err != nil { if err := ss.Command().PermanentDeleteByTeam(o1.TeamId); 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 {

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

@@ -103,15 +103,15 @@ func (_m *CommandStore) GetByTrigger(teamId string, trigger string) store.StoreC
} }
// PermanentDeleteByTeam provides a mock function with given fields: teamId // PermanentDeleteByTeam provides a mock function with given fields: teamId
func (_m *CommandStore) PermanentDeleteByTeam(teamId string) store.StoreChannel { func (_m *CommandStore) PermanentDeleteByTeam(teamId string) *model.AppError {
ret := _m.Called(teamId) ret := _m.Called(teamId)
var r0 store.StoreChannel var r0 *model.AppError
if rf, ok := ret.Get(0).(func(string) store.StoreChannel); ok { if rf, ok := ret.Get(0).(func(string) *model.AppError); ok {
r0 = rf(teamId) r0 = rf(teamId)
} else { } else {
if ret.Get(0) != nil { if ret.Get(0) != nil {
r0 = ret.Get(0).(store.StoreChannel) r0 = ret.Get(0).(*model.AppError)
} }
} }