[MM-16168] Migrate Team.GetAllTeamListing to Sync by default (#11102)
* [MM-16168] Migrate Team.GetAllTeamListing to Sync by default * reverting GetAllTeamPageListing modification * Modifying app/team.go * Simplifying code
Этот коммит содержится в:
коммит произвёл
Jesús Espino
родитель
eb0268f108
Коммит
6fc0ec06b2
@@ -634,11 +634,7 @@ func (a *App) GetAllPrivateTeamsPage(offset int, limit int) ([]*model.Team, *mod
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) GetAllPublicTeams() ([]*model.Team, *model.AppError) {
|
func (a *App) GetAllPublicTeams() ([]*model.Team, *model.AppError) {
|
||||||
result := <-a.Srv.Store.Team().GetAllTeamListing()
|
return a.Srv.Store.Team().GetAllTeamListing()
|
||||||
if result.Err != nil {
|
|
||||||
return nil, result.Err
|
|
||||||
}
|
|
||||||
return result.Data.([]*model.Team), nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) GetAllPublicTeamsPage(offset int, limit int) ([]*model.Team, *model.AppError) {
|
func (a *App) GetAllPublicTeamsPage(offset int, limit int) ([]*model.Team, *model.AppError) {
|
||||||
|
|||||||
@@ -418,22 +418,19 @@ func (s SqlTeamStore) GetAllPrivateTeamPageListing(offset int, limit int) ([]*mo
|
|||||||
return data, nil
|
return data, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SqlTeamStore) GetAllTeamListing() store.StoreChannel {
|
func (s SqlTeamStore) GetAllTeamListing() ([]*model.Team, *model.AppError) {
|
||||||
return store.Do(func(result *store.StoreResult) {
|
query := "SELECT * FROM Teams WHERE AllowOpenInvite = 1 ORDER BY DisplayName"
|
||||||
query := "SELECT * FROM Teams WHERE AllowOpenInvite = 1 ORDER BY DisplayName"
|
|
||||||
|
|
||||||
if s.DriverName() == model.DATABASE_DRIVER_POSTGRES {
|
if s.DriverName() == model.DATABASE_DRIVER_POSTGRES {
|
||||||
query = "SELECT * FROM Teams WHERE AllowOpenInvite = true ORDER BY DisplayName"
|
query = "SELECT * FROM Teams WHERE AllowOpenInvite = true ORDER BY DisplayName"
|
||||||
}
|
}
|
||||||
|
|
||||||
var data []*model.Team
|
var data []*model.Team
|
||||||
if _, err := s.GetReplica().Select(&data, query); err != nil {
|
if _, err := s.GetReplica().Select(&data, query); err != nil {
|
||||||
result.Err = model.NewAppError("SqlTeamStore.GetAllTeamListing", "store.sql_team.get_all_team_listing.app_error", nil, err.Error(), http.StatusInternalServerError)
|
return nil, model.NewAppError("SqlTeamStore.GetAllTeamListing", "store.sql_team.get_all_team_listing.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
}
|
||||||
}
|
|
||||||
|
|
||||||
result.Data = data
|
return data, nil
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SqlTeamStore) GetAllTeamPageListing(offset int, limit int) ([]*model.Team, *model.AppError) {
|
func (s SqlTeamStore) GetAllTeamPageListing(offset int, limit int) ([]*model.Team, *model.AppError) {
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ type TeamStore interface {
|
|||||||
GetAllPage(offset int, limit int) ([]*model.Team, *model.AppError)
|
GetAllPage(offset int, limit int) ([]*model.Team, *model.AppError)
|
||||||
GetAllPrivateTeamListing() ([]*model.Team, *model.AppError)
|
GetAllPrivateTeamListing() ([]*model.Team, *model.AppError)
|
||||||
GetAllPrivateTeamPageListing(offset int, limit int) ([]*model.Team, *model.AppError)
|
GetAllPrivateTeamPageListing(offset int, limit int) ([]*model.Team, *model.AppError)
|
||||||
GetAllTeamListing() StoreChannel
|
GetAllTeamListing() ([]*model.Team, *model.AppError)
|
||||||
GetAllTeamPageListing(offset int, limit int) ([]*model.Team, *model.AppError)
|
GetAllTeamPageListing(offset int, limit int) ([]*model.Team, *model.AppError)
|
||||||
GetTeamsByUserId(userId string) StoreChannel
|
GetTeamsByUserId(userId string) StoreChannel
|
||||||
GetByInviteId(inviteId string) (*model.Team, *model.AppError)
|
GetByInviteId(inviteId string) (*model.Team, *model.AppError)
|
||||||
|
|||||||
@@ -247,19 +247,28 @@ func (_m *TeamStore) GetAllPrivateTeamPageListing(offset int, limit int) ([]*mod
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetAllTeamListing provides a mock function with given fields:
|
// GetAllTeamListing provides a mock function with given fields:
|
||||||
func (_m *TeamStore) GetAllTeamListing() store.StoreChannel {
|
func (_m *TeamStore) GetAllTeamListing() ([]*model.Team, *model.AppError) {
|
||||||
ret := _m.Called()
|
ret := _m.Called()
|
||||||
|
|
||||||
var r0 store.StoreChannel
|
var r0 []*model.Team
|
||||||
if rf, ok := ret.Get(0).(func() store.StoreChannel); ok {
|
if rf, ok := ret.Get(0).(func() []*model.Team); 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.Team)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAllTeamPageListing provides a mock function with given fields: offset, limit
|
// GetAllTeamPageListing provides a mock function with given fields: offset, limit
|
||||||
|
|||||||
@@ -481,11 +481,9 @@ func testGetAllTeamListing(t *testing.T, ss store.Store) {
|
|||||||
_, err = ss.Team().Save(&o4)
|
_, err = ss.Team().Save(&o4)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
if r1 := <-ss.Team().GetAllTeamListing(); r1.Err != nil {
|
if teams, err := ss.Team().GetAllTeamListing(); err != nil {
|
||||||
t.Fatal(r1.Err)
|
t.Fatal(err)
|
||||||
} else {
|
} else {
|
||||||
teams := r1.Data.([]*model.Team)
|
|
||||||
|
|
||||||
for _, team := range teams {
|
for _, team := range teams {
|
||||||
if !team.AllowOpenInvite {
|
if !team.AllowOpenInvite {
|
||||||
t.Fatal("should have returned team with AllowOpenInvite as true")
|
t.Fatal("should have returned team with AllowOpenInvite as true")
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user