[MM-16519] Migrate Status.GetOnlineAway to Sync by default (#11410)
* Made changes to status_store.go store/store.go * Modified test file and updated mocks
Этот коммит содержится в:
коммит произвёл
Michael Kochell
родитель
00bb39b2bd
Коммит
9bab407f26
@@ -96,15 +96,12 @@ func (s SqlStatusStore) GetByIds(userIds []string) ([]*model.Status, *model.AppE
|
||||
return statuses, nil
|
||||
}
|
||||
|
||||
func (s SqlStatusStore) GetOnlineAway() store.StoreChannel {
|
||||
return store.Do(func(result *store.StoreResult) {
|
||||
var statuses []*model.Status
|
||||
if _, err := s.GetReplica().Select(&statuses, "SELECT * FROM Status WHERE Status = :Online OR Status = :Away LIMIT 300", map[string]interface{}{"Online": model.STATUS_ONLINE, "Away": model.STATUS_AWAY}); err != nil {
|
||||
result.Err = model.NewAppError("SqlStatusStore.GetOnlineAway", "store.sql_status.get_online_away.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
} else {
|
||||
result.Data = statuses
|
||||
}
|
||||
})
|
||||
func (s SqlStatusStore) GetOnlineAway() ([]*model.Status, *model.AppError) {
|
||||
var statuses []*model.Status
|
||||
if _, err := s.GetReplica().Select(&statuses, "SELECT * FROM Status WHERE Status = :Online OR Status = :Away LIMIT 300", map[string]interface{}{"Online": model.STATUS_ONLINE, "Away": model.STATUS_AWAY}); err != nil {
|
||||
return nil, model.NewAppError("SqlStatusStore.GetOnlineAway", "store.sql_status.get_online_away.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
return statuses, nil
|
||||
}
|
||||
|
||||
func (s SqlStatusStore) GetOnline() ([]*model.Status, *model.AppError) {
|
||||
|
||||
@@ -470,7 +470,7 @@ type StatusStore interface {
|
||||
SaveOrUpdate(status *model.Status) *model.AppError
|
||||
Get(userId string) StoreChannel
|
||||
GetByIds(userIds []string) ([]*model.Status, *model.AppError)
|
||||
GetOnlineAway() StoreChannel
|
||||
GetOnlineAway() ([]*model.Status, *model.AppError)
|
||||
GetOnline() ([]*model.Status, *model.AppError)
|
||||
GetAllFromTeam(teamId string) ([]*model.Status, *model.AppError)
|
||||
ResetAll() StoreChannel
|
||||
|
||||
@@ -105,19 +105,28 @@ func (_m *StatusStore) GetOnline() ([]*model.Status, *model.AppError) {
|
||||
}
|
||||
|
||||
// GetOnlineAway provides a mock function with given fields:
|
||||
func (_m *StatusStore) GetOnlineAway() store.StoreChannel {
|
||||
func (_m *StatusStore) GetOnlineAway() ([]*model.Status, *model.AppError) {
|
||||
ret := _m.Called()
|
||||
|
||||
var r0 store.StoreChannel
|
||||
if rf, ok := ret.Get(0).(func() store.StoreChannel); ok {
|
||||
var r0 []*model.Status
|
||||
if rf, ok := ret.Get(0).(func() []*model.Status); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(store.StoreChannel)
|
||||
r0 = ret.Get(0).([]*model.Status)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func() *model.AppError); ok {
|
||||
r1 = rf()
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetTotalActiveUsersCount provides a mock function with given fields:
|
||||
|
||||
@@ -36,10 +36,9 @@ func testStatusStore(t *testing.T, ss store.Store) {
|
||||
status3 := &model.Status{UserId: model.NewId(), Status: model.STATUS_OFFLINE, Manual: false, LastActivityAt: 0, ActiveChannel: ""}
|
||||
require.Nil(t, ss.Status().SaveOrUpdate(status3))
|
||||
|
||||
if result := <-ss.Status().GetOnlineAway(); result.Err != nil {
|
||||
t.Fatal(result.Err)
|
||||
if statuses, err := ss.Status().GetOnlineAway(); err != nil {
|
||||
t.Fatal(err)
|
||||
} else {
|
||||
statuses := result.Data.([]*model.Status)
|
||||
for _, status := range statuses {
|
||||
if status.Status == model.STATUS_OFFLINE {
|
||||
t.Fatal("should not have returned offline statuses")
|
||||
|
||||
Ссылка в новой задаче
Block a user