[MM-16520] Migrate "Status.ResetAll" to Sync by default (#11424)

* Updated ResetAll function to return object

* Modified the defined interface

* Changed the data type where ResetAll was referrenced

* Refactored code

Changed user's email

* Fixed indentation
This commit is contained in:
SezalAgrawal
2019-06-28 15:02:57 +05:30
committed by George Goldberg
parent ea8d441345
commit a86b204105
5 changed files with 13 additions and 14 deletions

View File

@@ -234,8 +234,8 @@ func NewServer(options ...Option) (*Server, error) {
s.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableDeveloper = true }) s.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableDeveloper = true })
} }
if result := <-s.Store.Status().ResetAll(); result.Err != nil { if err := s.Store.Status().ResetAll(); err != nil {
mlog.Error(fmt.Sprint("Error to reset the server status.", result.Err.Error())) mlog.Error(fmt.Sprint("Error to reset the server status.", err.Error()))
} }
if s.joinCluster && s.Cluster != nil { if s.joinCluster && s.Cluster != nil {

View File

@@ -122,12 +122,11 @@ func (s SqlStatusStore) GetAllFromTeam(teamId string) ([]*model.Status, *model.A
return statuses, nil return statuses, nil
} }
func (s SqlStatusStore) ResetAll() store.StoreChannel { func (s SqlStatusStore) ResetAll() *model.AppError {
return store.Do(func(result *store.StoreResult) { if _, err := s.GetMaster().Exec("UPDATE Status SET Status = :Status WHERE Manual = false", map[string]interface{}{"Status": model.STATUS_OFFLINE}); err != nil {
if _, err := s.GetMaster().Exec("UPDATE Status SET Status = :Status WHERE Manual = false", map[string]interface{}{"Status": model.STATUS_OFFLINE}); err != nil { return model.NewAppError("SqlStatusStore.ResetAll", "store.sql_status.reset_all.app_error", nil, "", http.StatusInternalServerError)
result.Err = model.NewAppError("SqlStatusStore.ResetAll", "store.sql_status.reset_all.app_error", nil, "", http.StatusInternalServerError) }
} return nil
})
} }
func (s SqlStatusStore) GetTotalActiveUsersCount() (int64, *model.AppError) { func (s SqlStatusStore) GetTotalActiveUsersCount() (int64, *model.AppError) {

View File

@@ -473,7 +473,7 @@ type StatusStore interface {
GetOnlineAway() ([]*model.Status, *model.AppError) GetOnlineAway() ([]*model.Status, *model.AppError)
GetOnline() ([]*model.Status, *model.AppError) GetOnline() ([]*model.Status, *model.AppError)
GetAllFromTeam(teamId string) ([]*model.Status, *model.AppError) GetAllFromTeam(teamId string) ([]*model.Status, *model.AppError)
ResetAll() StoreChannel ResetAll() *model.AppError
GetTotalActiveUsersCount() (int64, *model.AppError) GetTotalActiveUsersCount() (int64, *model.AppError)
UpdateLastActivityAt(userId string, lastActivityAt int64) StoreChannel UpdateLastActivityAt(userId string, lastActivityAt int64) StoreChannel
} }

View File

@@ -153,15 +153,15 @@ func (_m *StatusStore) GetTotalActiveUsersCount() (int64, *model.AppError) {
} }
// ResetAll provides a mock function with given fields: // ResetAll provides a mock function with given fields:
func (_m *StatusStore) ResetAll() store.StoreChannel { func (_m *StatusStore) ResetAll() *model.AppError {
ret := _m.Called() ret := _m.Called()
var r0 store.StoreChannel var r0 *model.AppError
if rf, ok := ret.Get(0).(func() store.StoreChannel); ok { if rf, ok := ret.Get(0).(func() *model.AppError); ok {
r0 = rf() r0 = rf()
} else { } else {
if ret.Get(0) != nil { if ret.Get(0) != nil {
r0 = ret.Get(0).(store.StoreChannel) r0 = ret.Get(0).(*model.AppError)
} }
} }

View File

@@ -64,7 +64,7 @@ func testStatusStore(t *testing.T, ss store.Store) {
} }
} }
if err := (<-ss.Status().ResetAll()).Err; err != nil { if err := ss.Status().ResetAll(); err != nil {
t.Fatal(err) t.Fatal(err)
} }