Migrates Channel.GetAllChannelsForExportAfter to sync by default (#11273)
Этот коммит содержится в:
коммит произвёл
George Goldberg
родитель
2ce36c2eb1
Коммит
c40017b39d
@@ -146,14 +146,12 @@ func (a *App) ExportAllTeams(writer io.Writer) *model.AppError {
|
|||||||
func (a *App) ExportAllChannels(writer io.Writer) *model.AppError {
|
func (a *App) ExportAllChannels(writer io.Writer) *model.AppError {
|
||||||
afterId := strings.Repeat("0", 26)
|
afterId := strings.Repeat("0", 26)
|
||||||
for {
|
for {
|
||||||
result := <-a.Srv.Store.Channel().GetAllChannelsForExportAfter(1000, afterId)
|
channels, err := a.Srv.Store.Channel().GetAllChannelsForExportAfter(1000, afterId)
|
||||||
|
|
||||||
if result.Err != nil {
|
if err != nil {
|
||||||
return result.Err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
channels := result.Data.([]*model.ChannelForExport)
|
|
||||||
|
|
||||||
if len(channels) == 0 {
|
if len(channels) == 0 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2465,32 +2465,29 @@ func (s SqlChannelStore) ClearAllCustomRoleAssignments() *model.AppError {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SqlChannelStore) GetAllChannelsForExportAfter(limit int, afterId string) store.StoreChannel {
|
func (s SqlChannelStore) GetAllChannelsForExportAfter(limit int, afterId string) ([]*model.ChannelForExport, *model.AppError) {
|
||||||
return store.Do(func(result *store.StoreResult) {
|
var channels []*model.ChannelForExport
|
||||||
var data []*model.ChannelForExport
|
if _, err := s.GetReplica().Select(&channels, `
|
||||||
if _, err := s.GetReplica().Select(&data, `
|
SELECT
|
||||||
SELECT
|
Channels.*,
|
||||||
Channels.*,
|
Teams.Name as TeamName,
|
||||||
Teams.Name as TeamName,
|
Schemes.Name as SchemeName
|
||||||
Schemes.Name as SchemeName
|
FROM Channels
|
||||||
FROM Channels
|
INNER JOIN
|
||||||
INNER JOIN
|
Teams ON Channels.TeamId = Teams.Id
|
||||||
Teams ON Channels.TeamId = Teams.Id
|
LEFT JOIN
|
||||||
LEFT JOIN
|
Schemes ON Channels.SchemeId = Schemes.Id
|
||||||
Schemes ON Channels.SchemeId = Schemes.Id
|
WHERE
|
||||||
WHERE
|
Channels.Id > :AfterId
|
||||||
Channels.Id > :AfterId
|
AND Channels.Type IN ('O', 'P')
|
||||||
AND Channels.Type IN ('O', 'P')
|
ORDER BY
|
||||||
ORDER BY
|
Id
|
||||||
Id
|
LIMIT :Limit`,
|
||||||
LIMIT :Limit`,
|
map[string]interface{}{"AfterId": afterId, "Limit": limit}); err != nil {
|
||||||
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.Err = model.NewAppError("SqlChannelStore.GetAllChannelsForExportAfter", "store.sql_channel.get_all.app_error", nil, err.Error(), http.StatusInternalServerError)
|
}
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
result.Data = data
|
return channels, nil
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SqlChannelStore) GetChannelMembersForExport(userId string, teamId string) ([]*model.ChannelMemberForExport, *model.AppError) {
|
func (s SqlChannelStore) GetChannelMembersForExport(userId string, teamId string) ([]*model.ChannelMemberForExport, *model.AppError) {
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ type ChannelStore interface {
|
|||||||
ResetAllChannelSchemes() StoreChannel
|
ResetAllChannelSchemes() StoreChannel
|
||||||
ClearAllCustomRoleAssignments() *model.AppError
|
ClearAllCustomRoleAssignments() *model.AppError
|
||||||
MigratePublicChannels() error
|
MigratePublicChannels() error
|
||||||
GetAllChannelsForExportAfter(limit int, afterId string) StoreChannel
|
GetAllChannelsForExportAfter(limit int, afterId string) ([]*model.ChannelForExport, *model.AppError)
|
||||||
GetAllDirectChannelsForExportAfter(limit int, afterId string) StoreChannel
|
GetAllDirectChannelsForExportAfter(limit int, afterId string) StoreChannel
|
||||||
GetChannelMembersForExport(userId string, teamId string) ([]*model.ChannelMemberForExport, *model.AppError)
|
GetChannelMembersForExport(userId string, teamId string) ([]*model.ChannelMemberForExport, *model.AppError)
|
||||||
RemoveAllDeactivatedMembers(channelId string) *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)
|
_, err = ss.Channel().Save(&c1, -1)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
r1 := <-ss.Channel().GetAllChannelsForExportAfter(10000, strings.Repeat("0", 26))
|
d1, err := ss.Channel().GetAllChannelsForExportAfter(10000, strings.Repeat("0", 26))
|
||||||
assert.Nil(t, r1.Err)
|
assert.Nil(t, err)
|
||||||
d1 := r1.Data.([]*model.ChannelForExport)
|
|
||||||
|
|
||||||
found := false
|
found := false
|
||||||
for _, c := range d1 {
|
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
|
// 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)
|
ret := _m.Called(limit, afterId)
|
||||||
|
|
||||||
var r0 store.StoreChannel
|
var r0 []*model.ChannelForExport
|
||||||
if rf, ok := ret.Get(0).(func(int, string) store.StoreChannel); ok {
|
if rf, ok := ret.Get(0).(func(int, string) []*model.ChannelForExport); ok {
|
||||||
r0 = rf(limit, afterId)
|
r0 = rf(limit, afterId)
|
||||||
} else {
|
} else {
|
||||||
if ret.Get(0) != nil {
|
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
|
// GetAllDirectChannelsForExportAfter provides a mock function with given fields: limit, afterId
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user