mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
[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
This commit is contained in:
committed by
Jesús Espino
parent
eb0268f108
commit
6fc0ec06b2
@@ -634,11 +634,7 @@ func (a *App) GetAllPrivateTeamsPage(offset int, limit int) ([]*model.Team, *mod
|
||||
}
|
||||
|
||||
func (a *App) GetAllPublicTeams() ([]*model.Team, *model.AppError) {
|
||||
result := <-a.Srv.Store.Team().GetAllTeamListing()
|
||||
if result.Err != nil {
|
||||
return nil, result.Err
|
||||
}
|
||||
return result.Data.([]*model.Team), nil
|
||||
return a.Srv.Store.Team().GetAllTeamListing()
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
func (s SqlTeamStore) GetAllTeamListing() store.StoreChannel {
|
||||
return store.Do(func(result *store.StoreResult) {
|
||||
query := "SELECT * FROM Teams WHERE AllowOpenInvite = 1 ORDER BY DisplayName"
|
||||
func (s SqlTeamStore) GetAllTeamListing() ([]*model.Team, *model.AppError) {
|
||||
query := "SELECT * FROM Teams WHERE AllowOpenInvite = 1 ORDER BY DisplayName"
|
||||
|
||||
if s.DriverName() == model.DATABASE_DRIVER_POSTGRES {
|
||||
query = "SELECT * FROM Teams WHERE AllowOpenInvite = true ORDER BY DisplayName"
|
||||
}
|
||||
if s.DriverName() == model.DATABASE_DRIVER_POSTGRES {
|
||||
query = "SELECT * FROM Teams WHERE AllowOpenInvite = true ORDER BY DisplayName"
|
||||
}
|
||||
|
||||
var data []*model.Team
|
||||
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
|
||||
}
|
||||
var data []*model.Team
|
||||
if _, err := s.GetReplica().Select(&data, query); err != nil {
|
||||
return nil, model.NewAppError("SqlTeamStore.GetAllTeamListing", "store.sql_team.get_all_team_listing.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
result.Data = data
|
||||
})
|
||||
return data, nil
|
||||
}
|
||||
|
||||
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)
|
||||
GetAllPrivateTeamListing() ([]*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)
|
||||
GetTeamsByUserId(userId string) StoreChannel
|
||||
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:
|
||||
func (_m *TeamStore) GetAllTeamListing() store.StoreChannel {
|
||||
func (_m *TeamStore) GetAllTeamListing() ([]*model.Team, *model.AppError) {
|
||||
ret := _m.Called()
|
||||
|
||||
var r0 store.StoreChannel
|
||||
if rf, ok := ret.Get(0).(func() store.StoreChannel); ok {
|
||||
var r0 []*model.Team
|
||||
if rf, ok := ret.Get(0).(func() []*model.Team); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
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
|
||||
|
||||
@@ -481,11 +481,9 @@ func testGetAllTeamListing(t *testing.T, ss store.Store) {
|
||||
_, err = ss.Team().Save(&o4)
|
||||
require.Nil(t, err)
|
||||
|
||||
if r1 := <-ss.Team().GetAllTeamListing(); r1.Err != nil {
|
||||
t.Fatal(r1.Err)
|
||||
if teams, err := ss.Team().GetAllTeamListing(); err != nil {
|
||||
t.Fatal(err)
|
||||
} else {
|
||||
teams := r1.Data.([]*model.Team)
|
||||
|
||||
for _, team := range teams {
|
||||
if !team.AllowOpenInvite {
|
||||
t.Fatal("should have returned team with AllowOpenInvite as true")
|
||||
|
||||
Reference in New Issue
Block a user