mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Migrates Status.GetOnline to sync by default (#11351)
* Status.GetOnline to sync by default * Removed else sentence
This commit is contained in:
committed by
Jesús Espino
parent
162a2a9903
commit
0199cef145
@@ -111,15 +111,12 @@ func (s SqlStatusStore) GetOnlineAway() store.StoreChannel {
|
||||
})
|
||||
}
|
||||
|
||||
func (s SqlStatusStore) GetOnline() 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", map[string]interface{}{"Online": model.STATUS_ONLINE}); err != nil {
|
||||
result.Err = model.NewAppError("SqlStatusStore.GetOnline", "store.sql_status.get_online.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
} else {
|
||||
result.Data = statuses
|
||||
}
|
||||
})
|
||||
func (s SqlStatusStore) GetOnline() ([]*model.Status, *model.AppError) {
|
||||
var statuses []*model.Status
|
||||
if _, err := s.GetReplica().Select(&statuses, "SELECT * FROM Status WHERE Status = :Online", map[string]interface{}{"Online": model.STATUS_ONLINE}); err != nil {
|
||||
return nil, model.NewAppError("SqlStatusStore.GetOnline", "store.sql_status.get_online.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
return statuses, nil
|
||||
}
|
||||
|
||||
func (s SqlStatusStore) GetAllFromTeam(teamId string) store.StoreChannel {
|
||||
|
||||
@@ -470,7 +470,7 @@ type StatusStore interface {
|
||||
Get(userId string) StoreChannel
|
||||
GetByIds(userIds []string) StoreChannel
|
||||
GetOnlineAway() StoreChannel
|
||||
GetOnline() StoreChannel
|
||||
GetOnline() ([]*model.Status, *model.AppError)
|
||||
GetAllFromTeam(teamId string) StoreChannel
|
||||
ResetAll() StoreChannel
|
||||
GetTotalActiveUsersCount() StoreChannel
|
||||
|
||||
@@ -62,19 +62,28 @@ func (_m *StatusStore) GetByIds(userIds []string) store.StoreChannel {
|
||||
}
|
||||
|
||||
// GetOnline provides a mock function with given fields:
|
||||
func (_m *StatusStore) GetOnline() store.StoreChannel {
|
||||
func (_m *StatusStore) GetOnline() ([]*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
|
||||
}
|
||||
|
||||
// GetOnlineAway provides a mock function with given fields:
|
||||
|
||||
@@ -58,10 +58,9 @@ func testStatusStore(t *testing.T, ss store.Store) {
|
||||
}
|
||||
}
|
||||
|
||||
if result := <-ss.Status().GetOnline(); result.Err != nil {
|
||||
t.Fatal(result.Err)
|
||||
if statuses, err := ss.Status().GetOnline(); err != nil {
|
||||
t.Fatal(err)
|
||||
} else {
|
||||
statuses := result.Data.([]*model.Status)
|
||||
for _, status := range statuses {
|
||||
if status.Status != model.STATUS_ONLINE {
|
||||
t.Fatal("should not have returned offline statuses")
|
||||
|
||||
Reference in New Issue
Block a user