Migrate Groups store to sync by default (GetGroups and Counts) (#10998)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
b3118ce605
Коммит
76e00b406e
34
app/group.go
34
app/group.go
@@ -150,41 +150,33 @@ func (a *App) ChannelMembersToRemove() ([]*model.ChannelMember, *model.AppError)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) GetGroupsByChannel(channelId string, opts model.GroupSearchOpts) ([]*model.Group, int, *model.AppError) {
|
func (a *App) GetGroupsByChannel(channelId string, opts model.GroupSearchOpts) ([]*model.Group, int, *model.AppError) {
|
||||||
result := <-a.Srv.Store.Group().GetGroupsByChannel(channelId, opts)
|
groups, err := a.Srv.Store.Group().GetGroupsByChannel(channelId, opts)
|
||||||
if result.Err != nil {
|
if err != nil {
|
||||||
return nil, 0, result.Err
|
return nil, 0, err
|
||||||
}
|
}
|
||||||
groups := result.Data.([]*model.Group)
|
|
||||||
|
|
||||||
result = <-a.Srv.Store.Group().CountGroupsByChannel(channelId, opts)
|
count, err := a.Srv.Store.Group().CountGroupsByChannel(channelId, opts)
|
||||||
if result.Err != nil {
|
if err != nil {
|
||||||
return nil, 0, result.Err
|
return nil, 0, err
|
||||||
}
|
}
|
||||||
count := result.Data.(int64)
|
|
||||||
|
|
||||||
return groups, int(count), nil
|
return groups, int(count), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) GetGroupsByTeam(teamId string, opts model.GroupSearchOpts) ([]*model.Group, int, *model.AppError) {
|
func (a *App) GetGroupsByTeam(teamId string, opts model.GroupSearchOpts) ([]*model.Group, int, *model.AppError) {
|
||||||
result := <-a.Srv.Store.Group().GetGroupsByTeam(teamId, opts)
|
groups, err := a.Srv.Store.Group().GetGroupsByTeam(teamId, opts)
|
||||||
if result.Err != nil {
|
if err != nil {
|
||||||
return nil, 0, result.Err
|
return nil, 0, err
|
||||||
}
|
}
|
||||||
groups := result.Data.([]*model.Group)
|
|
||||||
|
|
||||||
result = <-a.Srv.Store.Group().CountGroupsByTeam(teamId, opts)
|
count, err := a.Srv.Store.Group().CountGroupsByTeam(teamId, opts)
|
||||||
if result.Err != nil {
|
if err != nil {
|
||||||
return nil, 0, result.Err
|
return nil, 0, err
|
||||||
}
|
}
|
||||||
count := result.Data.(int64)
|
|
||||||
|
|
||||||
return groups, int(count), nil
|
return groups, int(count), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) GetGroups(page, perPage int, opts model.GroupSearchOpts) ([]*model.Group, *model.AppError) {
|
func (a *App) GetGroups(page, perPage int, opts model.GroupSearchOpts) ([]*model.Group, *model.AppError) {
|
||||||
result := <-a.Srv.Store.Group().GetGroups(page, perPage, opts)
|
return a.Srv.Store.Group().GetGroups(page, perPage, opts)
|
||||||
if result.Err != nil {
|
|
||||||
return nil, result.Err
|
|
||||||
}
|
|
||||||
return result.Data.([]*model.Group), nil
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -836,57 +836,43 @@ func (s *SqlGroupStore) TeamMembersToRemove() ([]*model.TeamMember, *model.AppEr
|
|||||||
return teamMembers, nil
|
return teamMembers, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SqlGroupStore) CountGroupsByChannel(channelId string, opts model.GroupSearchOpts) store.StoreChannel {
|
func (s *SqlGroupStore) CountGroupsByChannel(channelId string, opts model.GroupSearchOpts) (int64, *model.AppError) {
|
||||||
return store.Do(func(result *store.StoreResult) {
|
countQuery := s.groupsBySyncableBaseQuery(model.GroupSyncableTypeChannel, selectCountGroups, channelId, opts)
|
||||||
|
|
||||||
countQuery := s.groupsBySyncableBaseQuery(model.GroupSyncableTypeChannel, selectCountGroups, channelId, opts)
|
countQueryString, args, err := countQuery.ToSql()
|
||||||
|
if err != nil {
|
||||||
|
return int64(0), model.NewAppError("SqlGroupStore.CountGroupsByChannel", "store.sql_group.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||||
|
}
|
||||||
|
|
||||||
countQueryString, args, err := countQuery.ToSql()
|
count, err := s.GetReplica().SelectInt(countQueryString, args...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
result.Err = model.NewAppError("SqlGroupStore.CountGroupsByChannel", "store.sql_group.app_error", nil, err.Error(), http.StatusInternalServerError)
|
return int64(0), model.NewAppError("SqlGroupStore.CountGroupsByChannel", "store.select_error", nil, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
}
|
||||||
}
|
|
||||||
|
|
||||||
count, err := s.GetReplica().SelectInt(countQueryString, args...)
|
return count, nil
|
||||||
if err != nil {
|
|
||||||
result.Err = model.NewAppError("SqlGroupStore.CountGroupsByChannel", "store.select_error", nil, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
result.Data = count
|
|
||||||
|
|
||||||
return
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SqlGroupStore) GetGroupsByChannel(channelId string, opts model.GroupSearchOpts) store.StoreChannel {
|
func (s *SqlGroupStore) GetGroupsByChannel(channelId string, opts model.GroupSearchOpts) ([]*model.Group, *model.AppError) {
|
||||||
return store.Do(func(result *store.StoreResult) {
|
query := s.groupsBySyncableBaseQuery(model.GroupSyncableTypeChannel, selectGroups, channelId, opts)
|
||||||
|
|
||||||
query := s.groupsBySyncableBaseQuery(model.GroupSyncableTypeChannel, selectGroups, channelId, opts)
|
if opts.PageOpts != nil {
|
||||||
|
offset := uint64(opts.PageOpts.Page * opts.PageOpts.PerPage)
|
||||||
|
query = query.OrderBy("ug.DisplayName").Limit(uint64(opts.PageOpts.PerPage)).Offset(offset)
|
||||||
|
}
|
||||||
|
|
||||||
if opts.PageOpts != nil {
|
queryString, args, err := query.ToSql()
|
||||||
offset := uint64(opts.PageOpts.Page * opts.PageOpts.PerPage)
|
if err != nil {
|
||||||
query = query.OrderBy("ug.DisplayName").Limit(uint64(opts.PageOpts.PerPage)).Offset(offset)
|
return nil, model.NewAppError("SqlGroupStore.GetGroupsByChannel", "store.sql_group.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
|
|
||||||
queryString, args, err := query.ToSql()
|
var groups []*model.Group
|
||||||
if err != nil {
|
|
||||||
result.Err = model.NewAppError("SqlGroupStore.GetGroupsByChannel", "store.sql_group.app_error", nil, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var groups []*model.Group
|
_, err = s.GetReplica().Select(&groups, queryString, args...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, model.NewAppError("SqlGroupStore.GetGroupsByChannel", "store.select_error", nil, err.Error(), http.StatusInternalServerError)
|
||||||
|
}
|
||||||
|
|
||||||
_, err = s.GetReplica().Select(&groups, queryString, args...)
|
return groups, nil
|
||||||
if err != nil {
|
|
||||||
result.Err = model.NewAppError("SqlGroupStore.GetGroupsByChannel", "store.select_error", nil, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
result.Data = groups
|
|
||||||
|
|
||||||
return
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChannelMembersToRemove returns all channel members that should be removed based on group constraints.
|
// ChannelMembersToRemove returns all channel members that should be removed based on group constraints.
|
||||||
@@ -985,86 +971,71 @@ func (s *SqlGroupStore) groupsBySyncableBaseQuery(st model.GroupSyncableType, t
|
|||||||
return query
|
return query
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SqlGroupStore) CountGroupsByTeam(teamId string, opts model.GroupSearchOpts) store.StoreChannel {
|
func (s *SqlGroupStore) CountGroupsByTeam(teamId string, opts model.GroupSearchOpts) (int64, *model.AppError) {
|
||||||
return store.Do(func(result *store.StoreResult) {
|
countQuery := s.groupsBySyncableBaseQuery(model.GroupSyncableTypeTeam, selectCountGroups, teamId, opts)
|
||||||
|
|
||||||
countQuery := s.groupsBySyncableBaseQuery(model.GroupSyncableTypeTeam, selectCountGroups, teamId, opts)
|
countQueryString, args, err := countQuery.ToSql()
|
||||||
|
if err != nil {
|
||||||
|
return int64(0), model.NewAppError("SqlGroupStore.CountGroupsByTeam", "store.sql_group.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||||
|
}
|
||||||
|
|
||||||
countQueryString, args, err := countQuery.ToSql()
|
count, err := s.GetReplica().SelectInt(countQueryString, args...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
result.Err = model.NewAppError("SqlGroupStore.CountGroupsByTeam", "store.sql_group.app_error", nil, err.Error(), http.StatusInternalServerError)
|
return int64(0), model.NewAppError("SqlGroupStore.CountGroupsByTeam", "store.select_error", nil, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
}
|
||||||
}
|
|
||||||
|
|
||||||
count, err := s.GetReplica().SelectInt(countQueryString, args...)
|
return count, nil
|
||||||
if err != nil {
|
|
||||||
result.Err = model.NewAppError("SqlGroupStore.CountGroupsByTeam", "store.select_error", nil, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
result.Data = count
|
|
||||||
|
|
||||||
return
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SqlGroupStore) GetGroupsByTeam(teamId string, opts model.GroupSearchOpts) store.StoreChannel {
|
func (s *SqlGroupStore) GetGroupsByTeam(teamId string, opts model.GroupSearchOpts) ([]*model.Group, *model.AppError) {
|
||||||
return store.Do(func(result *store.StoreResult) {
|
query := s.groupsBySyncableBaseQuery(model.GroupSyncableTypeTeam, selectGroups, teamId, opts)
|
||||||
|
|
||||||
query := s.groupsBySyncableBaseQuery(model.GroupSyncableTypeTeam, selectGroups, teamId, opts)
|
if opts.PageOpts != nil {
|
||||||
|
offset := uint64(opts.PageOpts.Page * opts.PageOpts.PerPage)
|
||||||
|
query = query.OrderBy("ug.DisplayName").Limit(uint64(opts.PageOpts.PerPage)).Offset(offset)
|
||||||
|
}
|
||||||
|
|
||||||
if opts.PageOpts != nil {
|
queryString, args, err := query.ToSql()
|
||||||
offset := uint64(opts.PageOpts.Page * opts.PageOpts.PerPage)
|
if err != nil {
|
||||||
query = query.OrderBy("ug.DisplayName").Limit(uint64(opts.PageOpts.PerPage)).Offset(offset)
|
return nil, model.NewAppError("SqlGroupStore.GetGroupsByTeam", "store.sql_group.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
|
|
||||||
queryString, args, err := query.ToSql()
|
var groups []*model.Group
|
||||||
if err != nil {
|
|
||||||
result.Err = model.NewAppError("SqlGroupStore.GetGroupsByTeam", "store.sql_group.app_error", nil, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var groups []*model.Group
|
_, err = s.GetReplica().Select(&groups, queryString, args...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, model.NewAppError("SqlGroupStore.GetGroupsByTeam", "store.select_error", nil, err.Error(), http.StatusInternalServerError)
|
||||||
|
}
|
||||||
|
|
||||||
_, err = s.GetReplica().Select(&groups, queryString, args...)
|
return groups, nil
|
||||||
if err != nil {
|
|
||||||
result.Err = model.NewAppError("SqlGroupStore.GetGroupsByTeam", "store.select_error", nil, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
result.Data = groups
|
|
||||||
|
|
||||||
return
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SqlGroupStore) GetGroups(page, perPage int, opts model.GroupSearchOpts) store.StoreChannel {
|
func (s *SqlGroupStore) GetGroups(page, perPage int, opts model.GroupSearchOpts) ([]*model.Group, *model.AppError) {
|
||||||
return store.Do(func(result *store.StoreResult) {
|
var groups []*model.Group
|
||||||
var groups []*model.Group
|
|
||||||
|
|
||||||
groupsQuery := s.getQueryBuilder().Select("g.*").From("UserGroups g").Limit(uint64(perPage)).Offset(uint64(page * perPage)).OrderBy("g.DisplayName")
|
groupsQuery := s.getQueryBuilder().Select("g.*").From("UserGroups g").Limit(uint64(perPage)).Offset(uint64(page * perPage)).OrderBy("g.DisplayName")
|
||||||
|
|
||||||
if opts.IncludeMemberCount {
|
if opts.IncludeMemberCount {
|
||||||
groupsQuery = s.getQueryBuilder().
|
groupsQuery = s.getQueryBuilder().
|
||||||
Select("g.*, coalesce(Members.MemberCount, 0) AS MemberCount").
|
Select("g.*, coalesce(Members.MemberCount, 0) AS MemberCount").
|
||||||
From("UserGroups g").
|
From("UserGroups g").
|
||||||
LeftJoin("(SELECT GroupMembers.GroupId, COUNT(*) AS MemberCount FROM GroupMembers WHERE GroupMembers.DeleteAt = 0 GROUP BY GroupId) AS Members ON Members.GroupId = g.Id").
|
LeftJoin("(SELECT GroupMembers.GroupId, COUNT(*) AS MemberCount FROM GroupMembers WHERE GroupMembers.DeleteAt = 0 GROUP BY GroupId) AS Members ON Members.GroupId = g.Id").
|
||||||
Limit(uint64(perPage)).
|
Limit(uint64(perPage)).
|
||||||
Offset(uint64(page * perPage)).
|
Offset(uint64(page * perPage)).
|
||||||
OrderBy("g.DisplayName")
|
OrderBy("g.DisplayName")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(opts.Q) > 0 {
|
||||||
|
pattern := fmt.Sprintf("%%%s%%", opts.Q)
|
||||||
|
operatorKeyword := "ILIKE"
|
||||||
|
if s.DriverName() == model.DATABASE_DRIVER_MYSQL {
|
||||||
|
operatorKeyword = "LIKE"
|
||||||
}
|
}
|
||||||
|
groupsQuery = groupsQuery.Where(fmt.Sprintf("(g.Name %[1]s ? OR g.DisplayName %[1]s ?)", operatorKeyword), pattern, pattern)
|
||||||
|
}
|
||||||
|
|
||||||
if len(opts.Q) > 0 {
|
if len(opts.NotAssociatedToTeam) == 26 {
|
||||||
pattern := fmt.Sprintf("%%%s%%", opts.Q)
|
groupsQuery = groupsQuery.Where(`
|
||||||
operatorKeyword := "ILIKE"
|
|
||||||
if s.DriverName() == model.DATABASE_DRIVER_MYSQL {
|
|
||||||
operatorKeyword = "LIKE"
|
|
||||||
}
|
|
||||||
groupsQuery = groupsQuery.Where(fmt.Sprintf("(g.Name %[1]s ? OR g.DisplayName %[1]s ?)", operatorKeyword), pattern, pattern)
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(opts.NotAssociatedToTeam) == 26 {
|
|
||||||
groupsQuery = groupsQuery.Where(`
|
|
||||||
g.Id NOT IN (
|
g.Id NOT IN (
|
||||||
SELECT
|
SELECT
|
||||||
Id
|
Id
|
||||||
@@ -1077,10 +1048,10 @@ func (s *SqlGroupStore) GetGroups(page, perPage int, opts model.GroupSearchOpts)
|
|||||||
AND GroupTeams.TeamId = ?
|
AND GroupTeams.TeamId = ?
|
||||||
)
|
)
|
||||||
`, opts.NotAssociatedToTeam)
|
`, opts.NotAssociatedToTeam)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(opts.NotAssociatedToChannel) == 26 {
|
if len(opts.NotAssociatedToChannel) == 26 {
|
||||||
groupsQuery = groupsQuery.Where(`
|
groupsQuery = groupsQuery.Where(`
|
||||||
g.Id NOT IN (
|
g.Id NOT IN (
|
||||||
SELECT
|
SELECT
|
||||||
Id
|
Id
|
||||||
@@ -1093,20 +1064,16 @@ func (s *SqlGroupStore) GetGroups(page, perPage int, opts model.GroupSearchOpts)
|
|||||||
AND GroupChannels.ChannelId = ?
|
AND GroupChannels.ChannelId = ?
|
||||||
)
|
)
|
||||||
`, opts.NotAssociatedToChannel)
|
`, opts.NotAssociatedToChannel)
|
||||||
}
|
}
|
||||||
|
|
||||||
queryString, args, err := groupsQuery.ToSql()
|
queryString, args, err := groupsQuery.ToSql()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
result.Err = model.NewAppError("SqlGroupStore.GetGroups", "store.sql_group.app_error", nil, err.Error(), http.StatusInternalServerError)
|
return nil, model.NewAppError("SqlGroupStore.GetGroups", "store.sql_group.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if _, err = s.GetReplica().Select(&groups, queryString, args...); err != nil {
|
if _, err = s.GetReplica().Select(&groups, queryString, args...); err != nil {
|
||||||
result.Err = model.NewAppError("SqlGroupStore.GetGroups", "store.select_error", nil, err.Error(), http.StatusInternalServerError)
|
return nil, model.NewAppError("SqlGroupStore.GetGroups", "store.select_error", nil, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
}
|
||||||
}
|
|
||||||
|
|
||||||
result.Data = groups
|
return groups, nil
|
||||||
return
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -594,13 +594,13 @@ type GroupStore interface {
|
|||||||
TeamMembersToRemove() ([]*model.TeamMember, *model.AppError)
|
TeamMembersToRemove() ([]*model.TeamMember, *model.AppError)
|
||||||
ChannelMembersToRemove() ([]*model.ChannelMember, *model.AppError)
|
ChannelMembersToRemove() ([]*model.ChannelMember, *model.AppError)
|
||||||
|
|
||||||
GetGroupsByChannel(channelId string, opts model.GroupSearchOpts) StoreChannel
|
GetGroupsByChannel(channelId string, opts model.GroupSearchOpts) ([]*model.Group, *model.AppError)
|
||||||
CountGroupsByChannel(channelId string, opts model.GroupSearchOpts) StoreChannel
|
CountGroupsByChannel(channelId string, opts model.GroupSearchOpts) (int64, *model.AppError)
|
||||||
|
|
||||||
GetGroupsByTeam(teamId string, opts model.GroupSearchOpts) StoreChannel
|
GetGroupsByTeam(teamId string, opts model.GroupSearchOpts) ([]*model.Group, *model.AppError)
|
||||||
CountGroupsByTeam(teamId string, opts model.GroupSearchOpts) StoreChannel
|
CountGroupsByTeam(teamId string, opts model.GroupSearchOpts) (int64, *model.AppError)
|
||||||
|
|
||||||
GetGroups(page, perPage int, opts model.GroupSearchOpts) StoreChannel
|
GetGroups(page, perPage int, opts model.GroupSearchOpts) ([]*model.Group, *model.AppError)
|
||||||
}
|
}
|
||||||
|
|
||||||
type LinkMetadataStore interface {
|
type LinkMetadataStore interface {
|
||||||
|
|||||||
@@ -1729,12 +1729,12 @@ func testGetGroupsByChannel(t *testing.T, ss store.Store) {
|
|||||||
}
|
}
|
||||||
tc.Opts.PageOpts.Page = tc.Page
|
tc.Opts.PageOpts.Page = tc.Page
|
||||||
tc.Opts.PageOpts.PerPage = tc.PerPage
|
tc.Opts.PageOpts.PerPage = tc.PerPage
|
||||||
res := <-ss.Group().GetGroupsByChannel(tc.ChannelId, tc.Opts)
|
groups, err := ss.Group().GetGroupsByChannel(tc.ChannelId, tc.Opts)
|
||||||
require.Nil(t, res.Err)
|
require.Nil(t, err)
|
||||||
require.ElementsMatch(t, tc.Result, res.Data.([]*model.Group))
|
require.ElementsMatch(t, tc.Result, groups)
|
||||||
if tc.TotalCount != nil {
|
if tc.TotalCount != nil {
|
||||||
res = <-ss.Group().CountGroupsByChannel(tc.ChannelId, tc.Opts)
|
var count int64
|
||||||
count := res.Data.(int64)
|
count, err = ss.Group().CountGroupsByChannel(tc.ChannelId, tc.Opts)
|
||||||
require.Equal(t, *tc.TotalCount, count)
|
require.Equal(t, *tc.TotalCount, count)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -1931,13 +1931,12 @@ func testGetGroupsByTeam(t *testing.T, ss store.Store) {
|
|||||||
}
|
}
|
||||||
tc.Opts.PageOpts.Page = tc.Page
|
tc.Opts.PageOpts.Page = tc.Page
|
||||||
tc.Opts.PageOpts.PerPage = tc.PerPage
|
tc.Opts.PageOpts.PerPage = tc.PerPage
|
||||||
res := <-ss.Group().GetGroupsByTeam(tc.TeamId, tc.Opts)
|
groups, err := ss.Group().GetGroupsByTeam(tc.TeamId, tc.Opts)
|
||||||
require.Nil(t, res.Err)
|
require.Nil(t, err)
|
||||||
groups := res.Data.([]*model.Group)
|
|
||||||
require.ElementsMatch(t, tc.Result, groups)
|
require.ElementsMatch(t, tc.Result, groups)
|
||||||
if tc.TotalCount != nil {
|
if tc.TotalCount != nil {
|
||||||
res = <-ss.Group().CountGroupsByTeam(tc.TeamId, tc.Opts)
|
var count int64
|
||||||
count := res.Data.(int64)
|
count, err = ss.Group().CountGroupsByTeam(tc.TeamId, tc.Opts)
|
||||||
require.Equal(t, *tc.TotalCount, count)
|
require.Equal(t, *tc.TotalCount, count)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -2209,9 +2208,8 @@ func testGetGroups(t *testing.T, ss store.Store) {
|
|||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
t.Run(tc.Name, func(t *testing.T) {
|
t.Run(tc.Name, func(t *testing.T) {
|
||||||
res := <-ss.Group().GetGroups(tc.Page, tc.PerPage, tc.Opts)
|
groups, err := ss.Group().GetGroups(tc.Page, tc.PerPage, tc.Opts)
|
||||||
require.Nil(t, res.Err)
|
require.Nil(t, err)
|
||||||
groups := res.Data.([]*model.Group)
|
|
||||||
require.True(t, tc.Resultf(groups))
|
require.True(t, tc.Resultf(groups))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,35 +64,49 @@ func (_m *GroupStore) ChannelMembersToRemove() ([]*model.ChannelMember, *model.A
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CountGroupsByChannel provides a mock function with given fields: channelId, opts
|
// CountGroupsByChannel provides a mock function with given fields: channelId, opts
|
||||||
func (_m *GroupStore) CountGroupsByChannel(channelId string, opts model.GroupSearchOpts) store.StoreChannel {
|
func (_m *GroupStore) CountGroupsByChannel(channelId string, opts model.GroupSearchOpts) (int64, *model.AppError) {
|
||||||
ret := _m.Called(channelId, opts)
|
ret := _m.Called(channelId, opts)
|
||||||
|
|
||||||
var r0 store.StoreChannel
|
var r0 int64
|
||||||
if rf, ok := ret.Get(0).(func(string, model.GroupSearchOpts) store.StoreChannel); ok {
|
if rf, ok := ret.Get(0).(func(string, model.GroupSearchOpts) int64); ok {
|
||||||
r0 = rf(channelId, opts)
|
r0 = rf(channelId, opts)
|
||||||
} else {
|
} else {
|
||||||
if ret.Get(0) != nil {
|
r0 = ret.Get(0).(int64)
|
||||||
r0 = ret.Get(0).(store.StoreChannel)
|
}
|
||||||
|
|
||||||
|
var r1 *model.AppError
|
||||||
|
if rf, ok := ret.Get(1).(func(string, model.GroupSearchOpts) *model.AppError); ok {
|
||||||
|
r1 = rf(channelId, opts)
|
||||||
|
} else {
|
||||||
|
if ret.Get(1) != nil {
|
||||||
|
r1 = ret.Get(1).(*model.AppError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return r0
|
return r0, r1
|
||||||
}
|
}
|
||||||
|
|
||||||
// CountGroupsByTeam provides a mock function with given fields: teamId, opts
|
// CountGroupsByTeam provides a mock function with given fields: teamId, opts
|
||||||
func (_m *GroupStore) CountGroupsByTeam(teamId string, opts model.GroupSearchOpts) store.StoreChannel {
|
func (_m *GroupStore) CountGroupsByTeam(teamId string, opts model.GroupSearchOpts) (int64, *model.AppError) {
|
||||||
ret := _m.Called(teamId, opts)
|
ret := _m.Called(teamId, opts)
|
||||||
|
|
||||||
var r0 store.StoreChannel
|
var r0 int64
|
||||||
if rf, ok := ret.Get(0).(func(string, model.GroupSearchOpts) store.StoreChannel); ok {
|
if rf, ok := ret.Get(0).(func(string, model.GroupSearchOpts) int64); ok {
|
||||||
r0 = rf(teamId, opts)
|
r0 = rf(teamId, opts)
|
||||||
} else {
|
} else {
|
||||||
if ret.Get(0) != nil {
|
r0 = ret.Get(0).(int64)
|
||||||
r0 = ret.Get(0).(store.StoreChannel)
|
}
|
||||||
|
|
||||||
|
var r1 *model.AppError
|
||||||
|
if rf, ok := ret.Get(1).(func(string, model.GroupSearchOpts) *model.AppError); ok {
|
||||||
|
r1 = rf(teamId, opts)
|
||||||
|
} else {
|
||||||
|
if ret.Get(1) != nil {
|
||||||
|
r1 = ret.Get(1).(*model.AppError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return r0
|
return r0, r1
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create provides a mock function with given fields: group
|
// Create provides a mock function with given fields: group
|
||||||
@@ -272,51 +286,78 @@ func (_m *GroupStore) GetGroupSyncable(groupID string, syncableID string, syncab
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetGroups provides a mock function with given fields: page, perPage, opts
|
// GetGroups provides a mock function with given fields: page, perPage, opts
|
||||||
func (_m *GroupStore) GetGroups(page int, perPage int, opts model.GroupSearchOpts) store.StoreChannel {
|
func (_m *GroupStore) GetGroups(page int, perPage int, opts model.GroupSearchOpts) ([]*model.Group, *model.AppError) {
|
||||||
ret := _m.Called(page, perPage, opts)
|
ret := _m.Called(page, perPage, opts)
|
||||||
|
|
||||||
var r0 store.StoreChannel
|
var r0 []*model.Group
|
||||||
if rf, ok := ret.Get(0).(func(int, int, model.GroupSearchOpts) store.StoreChannel); ok {
|
if rf, ok := ret.Get(0).(func(int, int, model.GroupSearchOpts) []*model.Group); ok {
|
||||||
r0 = rf(page, perPage, opts)
|
r0 = rf(page, perPage, opts)
|
||||||
} else {
|
} else {
|
||||||
if ret.Get(0) != nil {
|
if ret.Get(0) != nil {
|
||||||
r0 = ret.Get(0).(store.StoreChannel)
|
r0 = ret.Get(0).([]*model.Group)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return r0
|
var r1 *model.AppError
|
||||||
|
if rf, ok := ret.Get(1).(func(int, int, model.GroupSearchOpts) *model.AppError); ok {
|
||||||
|
r1 = rf(page, perPage, opts)
|
||||||
|
} else {
|
||||||
|
if ret.Get(1) != nil {
|
||||||
|
r1 = ret.Get(1).(*model.AppError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return r0, r1
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetGroupsByChannel provides a mock function with given fields: channelId, opts
|
// GetGroupsByChannel provides a mock function with given fields: channelId, opts
|
||||||
func (_m *GroupStore) GetGroupsByChannel(channelId string, opts model.GroupSearchOpts) store.StoreChannel {
|
func (_m *GroupStore) GetGroupsByChannel(channelId string, opts model.GroupSearchOpts) ([]*model.Group, *model.AppError) {
|
||||||
ret := _m.Called(channelId, opts)
|
ret := _m.Called(channelId, opts)
|
||||||
|
|
||||||
var r0 store.StoreChannel
|
var r0 []*model.Group
|
||||||
if rf, ok := ret.Get(0).(func(string, model.GroupSearchOpts) store.StoreChannel); ok {
|
if rf, ok := ret.Get(0).(func(string, model.GroupSearchOpts) []*model.Group); ok {
|
||||||
r0 = rf(channelId, opts)
|
r0 = rf(channelId, opts)
|
||||||
} else {
|
} else {
|
||||||
if ret.Get(0) != nil {
|
if ret.Get(0) != nil {
|
||||||
r0 = ret.Get(0).(store.StoreChannel)
|
r0 = ret.Get(0).([]*model.Group)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return r0
|
var r1 *model.AppError
|
||||||
|
if rf, ok := ret.Get(1).(func(string, model.GroupSearchOpts) *model.AppError); ok {
|
||||||
|
r1 = rf(channelId, opts)
|
||||||
|
} else {
|
||||||
|
if ret.Get(1) != nil {
|
||||||
|
r1 = ret.Get(1).(*model.AppError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return r0, r1
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetGroupsByTeam provides a mock function with given fields: teamId, opts
|
// GetGroupsByTeam provides a mock function with given fields: teamId, opts
|
||||||
func (_m *GroupStore) GetGroupsByTeam(teamId string, opts model.GroupSearchOpts) store.StoreChannel {
|
func (_m *GroupStore) GetGroupsByTeam(teamId string, opts model.GroupSearchOpts) ([]*model.Group, *model.AppError) {
|
||||||
ret := _m.Called(teamId, opts)
|
ret := _m.Called(teamId, opts)
|
||||||
|
|
||||||
var r0 store.StoreChannel
|
var r0 []*model.Group
|
||||||
if rf, ok := ret.Get(0).(func(string, model.GroupSearchOpts) store.StoreChannel); ok {
|
if rf, ok := ret.Get(0).(func(string, model.GroupSearchOpts) []*model.Group); ok {
|
||||||
r0 = rf(teamId, opts)
|
r0 = rf(teamId, opts)
|
||||||
} else {
|
} else {
|
||||||
if ret.Get(0) != nil {
|
if ret.Get(0) != nil {
|
||||||
r0 = ret.Get(0).(store.StoreChannel)
|
r0 = ret.Get(0).([]*model.Group)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return r0
|
var r1 *model.AppError
|
||||||
|
if rf, ok := ret.Get(1).(func(string, model.GroupSearchOpts) *model.AppError); ok {
|
||||||
|
r1 = rf(teamId, opts)
|
||||||
|
} else {
|
||||||
|
if ret.Get(1) != nil {
|
||||||
|
r1 = ret.Get(1).(*model.AppError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return r0, r1
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetMemberCount provides a mock function with given fields: groupID
|
// GetMemberCount provides a mock function with given fields: groupID
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user