Channel.GetPublicChannelsForTeam to sync by default (#11208)
* Channel.GetPublicChannelsForTeam to sync by default * var rename
Этот коммит содержится в:
коммит произвёл
Jesús Espino
родитель
be5c962913
Коммит
de8a60225b
@@ -1258,11 +1258,7 @@ func (a *App) GetPublicChannelsByIdsForTeam(teamId string, channelIds []string)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) GetPublicChannelsForTeam(teamId string, offset int, limit int) (*model.ChannelList, *model.AppError) {
|
func (a *App) GetPublicChannelsForTeam(teamId string, offset int, limit int) (*model.ChannelList, *model.AppError) {
|
||||||
result := <-a.Srv.Store.Channel().GetPublicChannelsForTeam(teamId, offset, limit)
|
return a.Srv.Store.Channel().GetPublicChannelsForTeam(teamId, offset, limit)
|
||||||
if result.Err != nil {
|
|
||||||
return nil, result.Err
|
|
||||||
}
|
|
||||||
return result.Data.(*model.ChannelList), nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) GetChannelMember(channelId string, userId string) (*model.ChannelMember, *model.AppError) {
|
func (a *App) GetChannelMember(channelId string, userId string) (*model.ChannelMember, *model.AppError) {
|
||||||
|
|||||||
@@ -1031,35 +1031,32 @@ func (s SqlChannelStore) GetMoreChannels(teamId string, userId string, offset in
|
|||||||
return channels, nil
|
return channels, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SqlChannelStore) GetPublicChannelsForTeam(teamId string, offset int, limit int) store.StoreChannel {
|
func (s SqlChannelStore) GetPublicChannelsForTeam(teamId string, offset int, limit int) (*model.ChannelList, *model.AppError) {
|
||||||
return store.Do(func(result *store.StoreResult) {
|
channels := &model.ChannelList{}
|
||||||
data := &model.ChannelList{}
|
_, err := s.GetReplica().Select(channels, `
|
||||||
_, err := s.GetReplica().Select(data, `
|
SELECT
|
||||||
SELECT
|
Channels.*
|
||||||
Channels.*
|
FROM
|
||||||
FROM
|
Channels
|
||||||
Channels
|
JOIN
|
||||||
JOIN
|
PublicChannels pc ON (pc.Id = Channels.Id)
|
||||||
PublicChannels pc ON (pc.Id = Channels.Id)
|
WHERE
|
||||||
WHERE
|
pc.TeamId = :TeamId
|
||||||
pc.TeamId = :TeamId
|
AND pc.DeleteAt = 0
|
||||||
AND pc.DeleteAt = 0
|
ORDER BY pc.DisplayName
|
||||||
ORDER BY pc.DisplayName
|
LIMIT :Limit
|
||||||
LIMIT :Limit
|
OFFSET :Offset
|
||||||
OFFSET :Offset
|
|
||||||
`, map[string]interface{}{
|
`, map[string]interface{}{
|
||||||
"TeamId": teamId,
|
"TeamId": teamId,
|
||||||
"Limit": limit,
|
"Limit": limit,
|
||||||
"Offset": offset,
|
"Offset": offset,
|
||||||
})
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
result.Err = model.NewAppError("SqlChannelStore.GetPublicChannelsForTeam", "store.sql_channel.get_public_channels.get.app_error", nil, "teamId="+teamId+", err="+err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
result.Data = data
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, model.NewAppError("SqlChannelStore.GetPublicChannelsForTeam", "store.sql_channel.get_public_channels.get.app_error", nil, "teamId="+teamId+", err="+err.Error(), http.StatusInternalServerError)
|
||||||
|
}
|
||||||
|
|
||||||
|
return channels, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SqlChannelStore) GetPublicChannelsByIdsForTeam(teamId string, channelIds []string) (*model.ChannelList, *model.AppError) {
|
func (s SqlChannelStore) GetPublicChannelsByIdsForTeam(teamId string, channelIds []string) (*model.ChannelList, *model.AppError) {
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ type ChannelStore interface {
|
|||||||
GetChannels(teamId string, userId string, includeDeleted bool) (*model.ChannelList, *model.AppError)
|
GetChannels(teamId string, userId string, includeDeleted bool) (*model.ChannelList, *model.AppError)
|
||||||
GetAllChannels(page, perPage int, opts ChannelSearchOpts) StoreChannel
|
GetAllChannels(page, perPage int, opts ChannelSearchOpts) StoreChannel
|
||||||
GetMoreChannels(teamId string, userId string, offset int, limit int) (*model.ChannelList, *model.AppError)
|
GetMoreChannels(teamId string, userId string, offset int, limit int) (*model.ChannelList, *model.AppError)
|
||||||
GetPublicChannelsForTeam(teamId string, offset int, limit int) StoreChannel
|
GetPublicChannelsForTeam(teamId string, offset int, limit int) (*model.ChannelList, *model.AppError)
|
||||||
GetPublicChannelsByIdsForTeam(teamId string, channelIds []string) (*model.ChannelList, *model.AppError)
|
GetPublicChannelsByIdsForTeam(teamId string, channelIds []string) (*model.ChannelList, *model.AppError)
|
||||||
GetChannelCounts(teamId string, userId string) (*model.ChannelCounts, *model.AppError)
|
GetChannelCounts(teamId string, userId string) (*model.ChannelCounts, *model.AppError)
|
||||||
GetTeamChannels(teamId string) (*model.ChannelList, *model.AppError)
|
GetTeamChannels(teamId string) (*model.ChannelList, *model.AppError)
|
||||||
|
|||||||
@@ -1359,9 +1359,9 @@ func testChannelStoreGetPublicChannelsForTeam(t *testing.T, ss store.Store) {
|
|||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
t.Run("only o1 initially listed in public channels", func(t *testing.T) {
|
t.Run("only o1 initially listed in public channels", func(t *testing.T) {
|
||||||
result := <-ss.Channel().GetPublicChannelsForTeam(teamId, 0, 100)
|
list, channelErr := ss.Channel().GetPublicChannelsForTeam(teamId, 0, 100)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, channelErr)
|
||||||
require.Equal(t, &model.ChannelList{&o1}, result.Data.(*model.ChannelList))
|
require.Equal(t, &model.ChannelList{&o1}, list)
|
||||||
})
|
})
|
||||||
|
|
||||||
// o4 is another public channel on the team
|
// o4 is another public channel on the team
|
||||||
@@ -1387,21 +1387,21 @@ func testChannelStoreGetPublicChannelsForTeam(t *testing.T, ss store.Store) {
|
|||||||
require.Nil(t, err, "channel should have been deleted")
|
require.Nil(t, err, "channel should have been deleted")
|
||||||
|
|
||||||
t.Run("both o1 and o4 listed in public channels", func(t *testing.T) {
|
t.Run("both o1 and o4 listed in public channels", func(t *testing.T) {
|
||||||
cresult := <-ss.Channel().GetPublicChannelsForTeam(teamId, 0, 100)
|
list, err := ss.Channel().GetPublicChannelsForTeam(teamId, 0, 100)
|
||||||
require.Nil(t, cresult.Err)
|
require.Nil(t, err)
|
||||||
require.Equal(t, &model.ChannelList{&o1, &o4}, cresult.Data.(*model.ChannelList))
|
require.Equal(t, &model.ChannelList{&o1, &o4}, list)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("only o1 listed in public channels with offset 0, limit 1", func(t *testing.T) {
|
t.Run("only o1 listed in public channels with offset 0, limit 1", func(t *testing.T) {
|
||||||
result := <-ss.Channel().GetPublicChannelsForTeam(teamId, 0, 1)
|
list, err := ss.Channel().GetPublicChannelsForTeam(teamId, 0, 1)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, err)
|
||||||
require.Equal(t, &model.ChannelList{&o1}, result.Data.(*model.ChannelList))
|
require.Equal(t, &model.ChannelList{&o1}, list)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("only o4 listed in public channels with offset 1, limit 1", func(t *testing.T) {
|
t.Run("only o4 listed in public channels with offset 1, limit 1", func(t *testing.T) {
|
||||||
result := <-ss.Channel().GetPublicChannelsForTeam(teamId, 1, 1)
|
list, err := ss.Channel().GetPublicChannelsForTeam(teamId, 1, 1)
|
||||||
require.Nil(t, result.Err)
|
require.Nil(t, err)
|
||||||
require.Equal(t, &model.ChannelList{&o4}, result.Data.(*model.ChannelList))
|
require.Equal(t, &model.ChannelList{&o4}, list)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("verify analytics for open channels", func(t *testing.T) {
|
t.Run("verify analytics for open channels", func(t *testing.T) {
|
||||||
|
|||||||
@@ -878,19 +878,28 @@ func (_m *ChannelStore) GetPublicChannelsByIdsForTeam(teamId string, channelIds
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetPublicChannelsForTeam provides a mock function with given fields: teamId, offset, limit
|
// GetPublicChannelsForTeam provides a mock function with given fields: teamId, offset, limit
|
||||||
func (_m *ChannelStore) GetPublicChannelsForTeam(teamId string, offset int, limit int) store.StoreChannel {
|
func (_m *ChannelStore) GetPublicChannelsForTeam(teamId string, offset int, limit int) (*model.ChannelList, *model.AppError) {
|
||||||
ret := _m.Called(teamId, offset, limit)
|
ret := _m.Called(teamId, offset, limit)
|
||||||
|
|
||||||
var r0 store.StoreChannel
|
var r0 *model.ChannelList
|
||||||
if rf, ok := ret.Get(0).(func(string, int, int) store.StoreChannel); ok {
|
if rf, ok := ret.Get(0).(func(string, int, int) *model.ChannelList); ok {
|
||||||
r0 = rf(teamId, offset, limit)
|
r0 = rf(teamId, offset, limit)
|
||||||
} else {
|
} else {
|
||||||
if ret.Get(0) != nil {
|
if ret.Get(0) != nil {
|
||||||
r0 = ret.Get(0).(store.StoreChannel)
|
r0 = ret.Get(0).(*model.ChannelList)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return r0
|
var r1 *model.AppError
|
||||||
|
if rf, ok := ret.Get(1).(func(string, int, int) *model.AppError); ok {
|
||||||
|
r1 = rf(teamId, offset, limit)
|
||||||
|
} else {
|
||||||
|
if ret.Get(1) != nil {
|
||||||
|
r1 = ret.Get(1).(*model.AppError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return r0, r1
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTeamChannels provides a mock function with given fields: teamId
|
// GetTeamChannels provides a mock function with given fields: teamId
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user