Migrates Channel.GetMembersForUserWithPagination to sync by default (#11232)
* Migrates Channel.AutocompleteInTeam, Channel.SearchInTeam and Channel.SearchMore to sync by default * Migrates Channel.GetMembersForUserWithPagination to sync by default
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
d0906a0c85
Коммит
cff942f5bf
@@ -1304,12 +1304,11 @@ func (a *App) GetChannelMembersForUser(teamId string, userId string) (*model.Cha
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) GetChannelMembersForUserWithPagination(teamId, userId string, page, perPage int) ([]*model.ChannelMember, *model.AppError) {
|
func (a *App) GetChannelMembersForUserWithPagination(teamId, userId string, page, perPage int) ([]*model.ChannelMember, *model.AppError) {
|
||||||
result := <-a.Srv.Store.Channel().GetMembersForUserWithPagination(teamId, userId, page, perPage)
|
m, err := a.Srv.Store.Channel().GetMembersForUserWithPagination(teamId, userId, page, perPage)
|
||||||
if result.Err != nil {
|
if err != nil {
|
||||||
return nil, result.Err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
m := result.Data.(*model.ChannelMembers)
|
|
||||||
members := make([]*model.ChannelMember, 0)
|
members := make([]*model.ChannelMember, 0)
|
||||||
if m != nil {
|
if m != nil {
|
||||||
for _, member := range *m {
|
for _, member := range *m {
|
||||||
|
|||||||
@@ -1897,19 +1897,16 @@ func (s SqlChannelStore) GetMembersForUser(teamId string, userId string) (*model
|
|||||||
return dbMembers.ToModel(), nil
|
return dbMembers.ToModel(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SqlChannelStore) GetMembersForUserWithPagination(teamId, userId string, page, perPage int) store.StoreChannel {
|
func (s SqlChannelStore) GetMembersForUserWithPagination(teamId, userId string, page, perPage int) (*model.ChannelMembers, *model.AppError) {
|
||||||
return store.Do(func(result *store.StoreResult) {
|
|
||||||
var dbMembers channelMemberWithSchemeRolesList
|
var dbMembers channelMemberWithSchemeRolesList
|
||||||
offset := page * perPage
|
offset := page * perPage
|
||||||
_, err := s.GetReplica().Select(&dbMembers, CHANNEL_MEMBERS_WITH_SCHEME_SELECT_QUERY+"WHERE ChannelMembers.UserId = :UserId Limit :Limit Offset :Offset", map[string]interface{}{"TeamId": teamId, "UserId": userId, "Limit": perPage, "Offset": offset})
|
_, err := s.GetReplica().Select(&dbMembers, CHANNEL_MEMBERS_WITH_SCHEME_SELECT_QUERY+"WHERE ChannelMembers.UserId = :UserId Limit :Limit Offset :Offset", map[string]interface{}{"TeamId": teamId, "UserId": userId, "Limit": perPage, "Offset": offset})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
result.Err = model.NewAppError("SqlChannelStore.GetMembersForUserWithPagination", "store.sql_channel.get_members.app_error", nil, "teamId="+teamId+", userId="+userId+", err="+err.Error(), http.StatusInternalServerError)
|
return nil, model.NewAppError("SqlChannelStore.GetMembersForUserWithPagination", "store.sql_channel.get_members.app_error", nil, "teamId="+teamId+", userId="+userId+", err="+err.Error(), http.StatusInternalServerError)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result.Data = dbMembers.ToModel()
|
return dbMembers.ToModel(), nil
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SqlChannelStore) AutocompleteInTeam(teamId string, term string, includeDeleted bool) (*model.ChannelList, *model.AppError) {
|
func (s SqlChannelStore) AutocompleteInTeam(teamId string, term string, includeDeleted bool) (*model.ChannelList, *model.AppError) {
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ type ChannelStore interface {
|
|||||||
IncrementMentionCount(channelId string, userId string) *model.AppError
|
IncrementMentionCount(channelId string, userId string) *model.AppError
|
||||||
AnalyticsTypeCount(teamId string, channelType string) (int64, *model.AppError)
|
AnalyticsTypeCount(teamId string, channelType string) (int64, *model.AppError)
|
||||||
GetMembersForUser(teamId string, userId string) (*model.ChannelMembers, *model.AppError)
|
GetMembersForUser(teamId string, userId string) (*model.ChannelMembers, *model.AppError)
|
||||||
GetMembersForUserWithPagination(teamId, userId string, page, perPage int) StoreChannel
|
GetMembersForUserWithPagination(teamId, userId string, page, perPage int) (*model.ChannelMembers, *model.AppError)
|
||||||
AutocompleteInTeam(teamId string, term string, includeDeleted bool) (*model.ChannelList, *model.AppError)
|
AutocompleteInTeam(teamId string, term string, includeDeleted bool) (*model.ChannelList, *model.AppError)
|
||||||
AutocompleteInTeamForSearch(teamId string, userId string, term string, includeDeleted bool) (*model.ChannelList, *model.AppError)
|
AutocompleteInTeamForSearch(teamId string, userId string, term string, includeDeleted bool) (*model.ChannelList, *model.AppError)
|
||||||
SearchAllChannels(term string, opts ChannelSearchOpts) (*model.ChannelListWithTeamData, *model.AppError)
|
SearchAllChannels(term string, opts ChannelSearchOpts) (*model.ChannelListWithTeamData, *model.AppError)
|
||||||
|
|||||||
@@ -1641,13 +1641,12 @@ func testChannelStoreGetMembersForUserWithPagination(t *testing.T, ss store.Stor
|
|||||||
m2.NotifyProps = model.GetDefaultChannelNotifyProps()
|
m2.NotifyProps = model.GetDefaultChannelNotifyProps()
|
||||||
store.Must(ss.Channel().SaveMember(&m2))
|
store.Must(ss.Channel().SaveMember(&m2))
|
||||||
|
|
||||||
cresult := <-ss.Channel().GetMembersForUserWithPagination(o1.TeamId, m1.UserId, 0, 1)
|
members, err := ss.Channel().GetMembersForUserWithPagination(o1.TeamId, m1.UserId, 0, 1)
|
||||||
members := cresult.Data.(*model.ChannelMembers)
|
require.Nil(t, err)
|
||||||
|
|
||||||
assert.Len(t, *members, 1)
|
assert.Len(t, *members, 1)
|
||||||
|
|
||||||
cresult = <-ss.Channel().GetMembersForUserWithPagination(o1.TeamId, m1.UserId, 1, 1)
|
members, err = ss.Channel().GetMembersForUserWithPagination(o1.TeamId, m1.UserId, 1, 1)
|
||||||
members = cresult.Data.(*model.ChannelMembers)
|
require.Nil(t, err)
|
||||||
assert.Len(t, *members, 1)
|
assert.Len(t, *members, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -898,19 +898,28 @@ func (_m *ChannelStore) GetMembersForUser(teamId string, userId string) (*model.
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetMembersForUserWithPagination provides a mock function with given fields: teamId, userId, page, perPage
|
// GetMembersForUserWithPagination provides a mock function with given fields: teamId, userId, page, perPage
|
||||||
func (_m *ChannelStore) GetMembersForUserWithPagination(teamId string, userId string, page int, perPage int) store.StoreChannel {
|
func (_m *ChannelStore) GetMembersForUserWithPagination(teamId string, userId string, page int, perPage int) (*model.ChannelMembers, *model.AppError) {
|
||||||
ret := _m.Called(teamId, userId, page, perPage)
|
ret := _m.Called(teamId, userId, page, perPage)
|
||||||
|
|
||||||
var r0 store.StoreChannel
|
var r0 *model.ChannelMembers
|
||||||
if rf, ok := ret.Get(0).(func(string, string, int, int) store.StoreChannel); ok {
|
if rf, ok := ret.Get(0).(func(string, string, int, int) *model.ChannelMembers); ok {
|
||||||
r0 = rf(teamId, userId, page, perPage)
|
r0 = rf(teamId, userId, page, perPage)
|
||||||
} else {
|
} else {
|
||||||
if ret.Get(0) != nil {
|
if ret.Get(0) != nil {
|
||||||
r0 = ret.Get(0).(store.StoreChannel)
|
r0 = ret.Get(0).(*model.ChannelMembers)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return r0
|
var r1 *model.AppError
|
||||||
|
if rf, ok := ret.Get(1).(func(string, string, int, int) *model.AppError); ok {
|
||||||
|
r1 = rf(teamId, userId, page, perPage)
|
||||||
|
} else {
|
||||||
|
if ret.Get(1) != nil {
|
||||||
|
r1 = ret.Get(1).(*model.AppError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return r0, r1
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetMoreChannels provides a mock function with given fields: teamId, userId, offset, limit
|
// GetMoreChannels provides a mock function with given fields: teamId, userId, offset, limit
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user