mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Migrates Channel.GetAllChannelsForExportAfter to sync by default (#11273)
This commit is contained in:
committed by
George Goldberg
parent
2ce36c2eb1
commit
c40017b39d
@@ -146,14 +146,12 @@ func (a *App) ExportAllTeams(writer io.Writer) *model.AppError {
|
||||
func (a *App) ExportAllChannels(writer io.Writer) *model.AppError {
|
||||
afterId := strings.Repeat("0", 26)
|
||||
for {
|
||||
result := <-a.Srv.Store.Channel().GetAllChannelsForExportAfter(1000, afterId)
|
||||
channels, err := a.Srv.Store.Channel().GetAllChannelsForExportAfter(1000, afterId)
|
||||
|
||||
if result.Err != nil {
|
||||
return result.Err
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
channels := result.Data.([]*model.ChannelForExport)
|
||||
|
||||
if len(channels) == 0 {
|
||||
break
|
||||
}
|
||||
|
||||
@@ -2465,32 +2465,29 @@ func (s SqlChannelStore) ClearAllCustomRoleAssignments() *model.AppError {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s SqlChannelStore) GetAllChannelsForExportAfter(limit int, afterId string) store.StoreChannel {
|
||||
return store.Do(func(result *store.StoreResult) {
|
||||
var data []*model.ChannelForExport
|
||||
if _, err := s.GetReplica().Select(&data, `
|
||||
SELECT
|
||||
Channels.*,
|
||||
Teams.Name as TeamName,
|
||||
Schemes.Name as SchemeName
|
||||
FROM Channels
|
||||
INNER JOIN
|
||||
Teams ON Channels.TeamId = Teams.Id
|
||||
LEFT JOIN
|
||||
Schemes ON Channels.SchemeId = Schemes.Id
|
||||
WHERE
|
||||
Channels.Id > :AfterId
|
||||
AND Channels.Type IN ('O', 'P')
|
||||
ORDER BY
|
||||
Id
|
||||
LIMIT :Limit`,
|
||||
map[string]interface{}{"AfterId": afterId, "Limit": limit}); err != nil {
|
||||
result.Err = model.NewAppError("SqlChannelStore.GetAllChannelsForExportAfter", "store.sql_channel.get_all.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
func (s SqlChannelStore) GetAllChannelsForExportAfter(limit int, afterId string) ([]*model.ChannelForExport, *model.AppError) {
|
||||
var channels []*model.ChannelForExport
|
||||
if _, err := s.GetReplica().Select(&channels, `
|
||||
SELECT
|
||||
Channels.*,
|
||||
Teams.Name as TeamName,
|
||||
Schemes.Name as SchemeName
|
||||
FROM Channels
|
||||
INNER JOIN
|
||||
Teams ON Channels.TeamId = Teams.Id
|
||||
LEFT JOIN
|
||||
Schemes ON Channels.SchemeId = Schemes.Id
|
||||
WHERE
|
||||
Channels.Id > :AfterId
|
||||
AND Channels.Type IN ('O', 'P')
|
||||
ORDER BY
|
||||
Id
|
||||
LIMIT :Limit`,
|
||||
map[string]interface{}{"AfterId": afterId, "Limit": limit}); err != nil {
|
||||
return nil, model.NewAppError("SqlChannelStore.GetAllChannelsForExportAfter", "store.sql_channel.get_all.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
result.Data = data
|
||||
})
|
||||
return channels, nil
|
||||
}
|
||||
|
||||
func (s SqlChannelStore) GetChannelMembersForExport(userId string, teamId string) ([]*model.ChannelMemberForExport, *model.AppError) {
|
||||
|
||||
@@ -194,7 +194,7 @@ type ChannelStore interface {
|
||||
ResetAllChannelSchemes() StoreChannel
|
||||
ClearAllCustomRoleAssignments() *model.AppError
|
||||
MigratePublicChannels() error
|
||||
GetAllChannelsForExportAfter(limit int, afterId string) StoreChannel
|
||||
GetAllChannelsForExportAfter(limit int, afterId string) ([]*model.ChannelForExport, *model.AppError)
|
||||
GetAllDirectChannelsForExportAfter(limit int, afterId string) StoreChannel
|
||||
GetChannelMembersForExport(userId string, teamId string) ([]*model.ChannelMemberForExport, *model.AppError)
|
||||
RemoveAllDeactivatedMembers(channelId string) *model.AppError
|
||||
|
||||
@@ -3290,9 +3290,8 @@ func testChannelStoreGetAllChannelsForExportAfter(t *testing.T, ss store.Store)
|
||||
_, err = ss.Channel().Save(&c1, -1)
|
||||
require.Nil(t, err)
|
||||
|
||||
r1 := <-ss.Channel().GetAllChannelsForExportAfter(10000, strings.Repeat("0", 26))
|
||||
assert.Nil(t, r1.Err)
|
||||
d1 := r1.Data.([]*model.ChannelForExport)
|
||||
d1, err := ss.Channel().GetAllChannelsForExportAfter(10000, strings.Repeat("0", 26))
|
||||
assert.Nil(t, err)
|
||||
|
||||
found := false
|
||||
for _, c := range d1 {
|
||||
|
||||
@@ -263,19 +263,28 @@ func (_m *ChannelStore) GetAllChannels(page int, perPage int, opts store.Channel
|
||||
}
|
||||
|
||||
// GetAllChannelsForExportAfter provides a mock function with given fields: limit, afterId
|
||||
func (_m *ChannelStore) GetAllChannelsForExportAfter(limit int, afterId string) store.StoreChannel {
|
||||
func (_m *ChannelStore) GetAllChannelsForExportAfter(limit int, afterId string) ([]*model.ChannelForExport, *model.AppError) {
|
||||
ret := _m.Called(limit, afterId)
|
||||
|
||||
var r0 store.StoreChannel
|
||||
if rf, ok := ret.Get(0).(func(int, string) store.StoreChannel); ok {
|
||||
var r0 []*model.ChannelForExport
|
||||
if rf, ok := ret.Get(0).(func(int, string) []*model.ChannelForExport); ok {
|
||||
r0 = rf(limit, afterId)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(store.StoreChannel)
|
||||
r0 = ret.Get(0).([]*model.ChannelForExport)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(int, string) *model.AppError); ok {
|
||||
r1 = rf(limit, afterId)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetAllDirectChannelsForExportAfter provides a mock function with given fields: limit, afterId
|
||||
|
||||
Reference in New Issue
Block a user