mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Migrate Channel.GetChannelsByScheme to Sync by default (#11278)
This commit is contained in:
committed by
Jesús Espino
parent
d1a594e504
commit
eea8df75b0
@@ -146,11 +146,7 @@ func (a *App) GetChannelsForScheme(scheme *model.Scheme, offset int, limit int)
|
|||||||
if err := a.IsPhase2MigrationCompleted(); err != nil {
|
if err := a.IsPhase2MigrationCompleted(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
result := <-a.Srv.Store.Channel().GetChannelsByScheme(scheme.Id, offset, limit)
|
return a.Srv.Store.Channel().GetChannelsByScheme(scheme.Id, offset, limit)
|
||||||
if result.Err != nil {
|
|
||||||
return nil, result.Err
|
|
||||||
}
|
|
||||||
return result.Data.(model.ChannelList), nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) IsPhase2MigrationCompleted() *model.AppError {
|
func (a *App) IsPhase2MigrationCompleted() *model.AppError {
|
||||||
|
|||||||
@@ -2352,16 +2352,13 @@ func (s SqlChannelStore) GetMembersByIds(channelId string, userIds []string) (*m
|
|||||||
return dbMembers.ToModel(), nil
|
return dbMembers.ToModel(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SqlChannelStore) GetChannelsByScheme(schemeId string, offset int, limit int) store.StoreChannel {
|
func (s SqlChannelStore) GetChannelsByScheme(schemeId string, offset int, limit int) (model.ChannelList, *model.AppError) {
|
||||||
return store.Do(func(result *store.StoreResult) {
|
var channels model.ChannelList
|
||||||
var channels model.ChannelList
|
_, err := s.GetReplica().Select(&channels, "SELECT * FROM Channels WHERE SchemeId = :SchemeId ORDER BY DisplayName LIMIT :Limit OFFSET :Offset", map[string]interface{}{"SchemeId": schemeId, "Offset": offset, "Limit": limit})
|
||||||
_, err := s.GetReplica().Select(&channels, "SELECT * FROM Channels WHERE SchemeId = :SchemeId ORDER BY DisplayName LIMIT :Limit OFFSET :Offset", map[string]interface{}{"SchemeId": schemeId, "Offset": offset, "Limit": limit})
|
if err != nil {
|
||||||
if err != nil {
|
return nil, model.NewAppError("SqlChannelStore.GetChannelsByScheme", "store.sql_channel.get_by_scheme.app_error", nil, "schemeId="+schemeId+" "+err.Error(), http.StatusInternalServerError)
|
||||||
result.Err = model.NewAppError("SqlChannelStore.GetChannelsByScheme", "store.sql_channel.get_by_scheme.app_error", nil, "schemeId="+schemeId+" "+err.Error(), http.StatusInternalServerError)
|
}
|
||||||
return
|
return channels, nil
|
||||||
}
|
|
||||||
result.Data = channels
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function does the Advanced Permissions Phase 2 migration for ChannelMember objects. It performs the migration
|
// This function does the Advanced Permissions Phase 2 migration for ChannelMember objects. It performs the migration
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ type ChannelStore interface {
|
|||||||
AnalyticsDeletedTypeCount(teamId string, channelType string) (int64, *model.AppError)
|
AnalyticsDeletedTypeCount(teamId string, channelType string) (int64, *model.AppError)
|
||||||
GetChannelUnread(channelId, userId string) (*model.ChannelUnread, *model.AppError)
|
GetChannelUnread(channelId, userId string) (*model.ChannelUnread, *model.AppError)
|
||||||
ClearCaches()
|
ClearCaches()
|
||||||
GetChannelsByScheme(schemeId string, offset int, limit int) StoreChannel
|
GetChannelsByScheme(schemeId string, offset int, limit int) (model.ChannelList, *model.AppError)
|
||||||
MigrateChannelMembers(fromChannelId string, fromUserId string) (map[string]string, *model.AppError)
|
MigrateChannelMembers(fromChannelId string, fromUserId string) (map[string]string, *model.AppError)
|
||||||
ResetAllChannelSchemes() *model.AppError
|
ResetAllChannelSchemes() *model.AppError
|
||||||
ClearAllCustomRoleAssignments() *model.AppError
|
ClearAllCustomRoleAssignments() *model.AppError
|
||||||
|
|||||||
@@ -3073,21 +3073,18 @@ func testChannelStoreGetChannelsByScheme(t *testing.T, ss store.Store) {
|
|||||||
_, _ = ss.Channel().Save(c3, 100)
|
_, _ = ss.Channel().Save(c3, 100)
|
||||||
|
|
||||||
// Get the channels by a valid Scheme ID.
|
// Get the channels by a valid Scheme ID.
|
||||||
res1 := <-ss.Channel().GetChannelsByScheme(s1.Id, 0, 100)
|
d1, err := ss.Channel().GetChannelsByScheme(s1.Id, 0, 100)
|
||||||
assert.Nil(t, res1.Err)
|
assert.Nil(t, err)
|
||||||
d1 := res1.Data.(model.ChannelList)
|
|
||||||
assert.Len(t, d1, 2)
|
assert.Len(t, d1, 2)
|
||||||
|
|
||||||
// Get the channels by a valid Scheme ID where there aren't any matching Channel.
|
// Get the channels by a valid Scheme ID where there aren't any matching Channel.
|
||||||
res2 := <-ss.Channel().GetChannelsByScheme(s2.Id, 0, 100)
|
d2, err := ss.Channel().GetChannelsByScheme(s2.Id, 0, 100)
|
||||||
assert.Nil(t, res2.Err)
|
assert.Nil(t, err)
|
||||||
d2 := res2.Data.(model.ChannelList)
|
|
||||||
assert.Len(t, d2, 0)
|
assert.Len(t, d2, 0)
|
||||||
|
|
||||||
// Get the channels by an invalid Scheme ID.
|
// Get the channels by an invalid Scheme ID.
|
||||||
res3 := <-ss.Channel().GetChannelsByScheme(model.NewId(), 0, 100)
|
d3, err := ss.Channel().GetChannelsByScheme(model.NewId(), 0, 100)
|
||||||
assert.Nil(t, res3.Err)
|
assert.Nil(t, err)
|
||||||
d3 := res3.Data.(model.ChannelList)
|
|
||||||
assert.Len(t, d3, 0)
|
assert.Len(t, d3, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -620,19 +620,28 @@ func (_m *ChannelStore) GetChannelsByIds(channelIds []string) ([]*model.Channel,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetChannelsByScheme provides a mock function with given fields: schemeId, offset, limit
|
// GetChannelsByScheme provides a mock function with given fields: schemeId, offset, limit
|
||||||
func (_m *ChannelStore) GetChannelsByScheme(schemeId string, offset int, limit int) store.StoreChannel {
|
func (_m *ChannelStore) GetChannelsByScheme(schemeId string, offset int, limit int) (model.ChannelList, *model.AppError) {
|
||||||
ret := _m.Called(schemeId, offset, limit)
|
ret := _m.Called(schemeId, 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(schemeId, offset, limit)
|
r0 = rf(schemeId, 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(schemeId, offset, limit)
|
||||||
|
} else {
|
||||||
|
if ret.Get(1) != nil {
|
||||||
|
r1 = ret.Get(1).(*model.AppError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return r0, r1
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDeleted provides a mock function with given fields: team_id, offset, limit
|
// GetDeleted provides a mock function with given fields: team_id, offset, limit
|
||||||
|
|||||||
Reference in New Issue
Block a user