Migrate Status.GetAllFromTeam method to Sync (#11362)
* Migrate Status.GetAllFromTeam method to Sync * remove redundant else statement in GetAllFromTeam
Этот коммит содержится в:
коммит произвёл
Jesús Espino
родитель
331ded2421
Коммит
453f28c05d
@@ -118,17 +118,14 @@ func (s SqlStatusStore) GetOnline() ([]*model.Status, *model.AppError) {
|
|||||||
return statuses, nil
|
return statuses, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SqlStatusStore) GetAllFromTeam(teamId string) store.StoreChannel {
|
func (s SqlStatusStore) GetAllFromTeam(teamId string) ([]*model.Status, *model.AppError) {
|
||||||
return store.Do(func(result *store.StoreResult) {
|
var statuses []*model.Status
|
||||||
var statuses []*model.Status
|
if _, err := s.GetReplica().Select(&statuses,
|
||||||
if _, err := s.GetReplica().Select(&statuses,
|
`SELECT s.* FROM Status AS s INNER JOIN
|
||||||
`SELECT s.* FROM Status AS s INNER JOIN
|
|
||||||
TeamMembers AS tm ON tm.TeamId=:TeamId AND s.UserId=tm.UserId`, map[string]interface{}{"TeamId": teamId}); err != nil {
|
TeamMembers AS tm ON tm.TeamId=:TeamId AND s.UserId=tm.UserId`, map[string]interface{}{"TeamId": teamId}); err != nil {
|
||||||
result.Err = model.NewAppError("SqlStatusStore.GetAllFromTeam", "store.sql_status.get_team_statuses.app_error", nil, err.Error(), http.StatusInternalServerError)
|
return nil, model.NewAppError("SqlStatusStore.GetAllFromTeam", "store.sql_status.get_team_statuses.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||||
} else {
|
}
|
||||||
result.Data = statuses
|
return statuses, nil
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SqlStatusStore) ResetAll() store.StoreChannel {
|
func (s SqlStatusStore) ResetAll() store.StoreChannel {
|
||||||
|
|||||||
@@ -471,7 +471,7 @@ type StatusStore interface {
|
|||||||
GetByIds(userIds []string) StoreChannel
|
GetByIds(userIds []string) StoreChannel
|
||||||
GetOnlineAway() StoreChannel
|
GetOnlineAway() StoreChannel
|
||||||
GetOnline() ([]*model.Status, *model.AppError)
|
GetOnline() ([]*model.Status, *model.AppError)
|
||||||
GetAllFromTeam(teamId string) StoreChannel
|
GetAllFromTeam(teamId string) ([]*model.Status, *model.AppError)
|
||||||
ResetAll() StoreChannel
|
ResetAll() StoreChannel
|
||||||
GetTotalActiveUsersCount() StoreChannel
|
GetTotalActiveUsersCount() StoreChannel
|
||||||
UpdateLastActivityAt(userId string, lastActivityAt int64) StoreChannel
|
UpdateLastActivityAt(userId string, lastActivityAt int64) StoreChannel
|
||||||
|
|||||||
@@ -30,19 +30,28 @@ func (_m *StatusStore) Get(userId string) store.StoreChannel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetAllFromTeam provides a mock function with given fields: teamId
|
// GetAllFromTeam provides a mock function with given fields: teamId
|
||||||
func (_m *StatusStore) GetAllFromTeam(teamId string) store.StoreChannel {
|
func (_m *StatusStore) GetAllFromTeam(teamId string) ([]*model.Status, *model.AppError) {
|
||||||
ret := _m.Called(teamId)
|
ret := _m.Called(teamId)
|
||||||
|
|
||||||
var r0 store.StoreChannel
|
var r0 []*model.Status
|
||||||
if rf, ok := ret.Get(0).(func(string) store.StoreChannel); ok {
|
if rf, ok := ret.Get(0).(func(string) []*model.Status); 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.Status)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return r0
|
var r1 *model.AppError
|
||||||
|
if rf, ok := ret.Get(1).(func(string) *model.AppError); ok {
|
||||||
|
r1 = rf(teamId)
|
||||||
|
} else {
|
||||||
|
if ret.Get(1) != nil {
|
||||||
|
r1 = ret.Get(1).(*model.AppError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return r0, r1
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetByIds provides a mock function with given fields: userIds
|
// GetByIds provides a mock function with given fields: userIds
|
||||||
|
|||||||
@@ -158,21 +158,21 @@ func testGetAllFromTeam(t *testing.T, ss store.Store) {
|
|||||||
team2Member2Status := &model.Status{UserId: team2Member2.UserId, Status: model.STATUS_OFFLINE, Manual: true, LastActivityAt: model.GetMillis(), ActiveChannel: ""}
|
team2Member2Status := &model.Status{UserId: team2Member2.UserId, Status: model.STATUS_OFFLINE, Manual: true, LastActivityAt: model.GetMillis(), ActiveChannel: ""}
|
||||||
require.Nil(t, ss.Status().SaveOrUpdate(team2Member2Status))
|
require.Nil(t, ss.Status().SaveOrUpdate(team2Member2Status))
|
||||||
|
|
||||||
if result := <-ss.Status().GetAllFromTeam(team1.Id); result.Err != nil {
|
if statueses, err := ss.Status().GetAllFromTeam(team1.Id); err != nil {
|
||||||
t.Fatal(result.Err)
|
t.Fatal(err)
|
||||||
} else {
|
} else {
|
||||||
assertStatuses([]*model.Status{
|
assertStatuses([]*model.Status{
|
||||||
team1Member1Status,
|
team1Member1Status,
|
||||||
team1Member2Status,
|
team1Member2Status,
|
||||||
}, result.Data.([]*model.Status))
|
}, statueses)
|
||||||
}
|
}
|
||||||
|
|
||||||
if result := <-ss.Status().GetAllFromTeam(team2.Id); result.Err != nil {
|
if statueses, err := ss.Status().GetAllFromTeam(team2.Id); err != nil {
|
||||||
t.Fatal(result.Err)
|
t.Fatal(err)
|
||||||
} else {
|
} else {
|
||||||
assertStatuses([]*model.Status{
|
assertStatuses([]*model.Status{
|
||||||
team2Member1Status,
|
team2Member1Status,
|
||||||
team2Member2Status,
|
team2Member2Status,
|
||||||
}, result.Data.([]*model.Status))
|
}, statueses)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user