Migrates "Channel.GetAll" to Sync by default (#11281)

Этот коммит содержится в:
piperRyan
2019-06-19 03:40:05 -06:00
коммит произвёл Miguel de la Cruz
родитель a02467698c
Коммит 2ce36c2eb1
5 изменённых файлов: 25 добавлений и 22 удалений

Просмотреть файл

@@ -444,11 +444,9 @@ func listChannelsCmdF(command *cobra.Command, args []string) error {
CommandPrintErrorln("Unable to find team '" + args[i] + "'") CommandPrintErrorln("Unable to find team '" + args[i] + "'")
continue continue
} }
if result := <-a.Srv.Store.Channel().GetAll(team.Id); result.Err != nil { if channels, chanErr := a.Srv.Store.Channel().GetAll(team.Id); chanErr != nil {
CommandPrintErrorln("Unable to list channels for '" + args[i] + "'") CommandPrintErrorln("Unable to list channels for '" + args[i] + "'")
} else { } else {
channels := result.Data.([]*model.Channel)
for _, channel := range channels { for _, channel := range channels {
if channel.DeleteAt > 0 { if channel.DeleteAt > 0 {
CommandPrettyPrintln(channel.Name + " (archived)") CommandPrettyPrintln(channel.Name + " (archived)")

Просмотреть файл

@@ -1829,18 +1829,15 @@ func (s SqlChannelStore) IncrementMentionCount(channelId string, userId string)
}) })
} }
func (s SqlChannelStore) GetAll(teamId string) store.StoreChannel { func (s SqlChannelStore) GetAll(teamId string) ([]*model.Channel, *model.AppError) {
return store.Do(func(result *store.StoreResult) { var data []*model.Channel
var data []*model.Channel _, err := s.GetReplica().Select(&data, "SELECT * FROM Channels WHERE TeamId = :TeamId AND Type != 'D' ORDER BY Name", map[string]interface{}{"TeamId": teamId})
_, err := s.GetReplica().Select(&data, "SELECT * FROM Channels WHERE TeamId = :TeamId AND Type != 'D' ORDER BY Name", map[string]interface{}{"TeamId": teamId})
if err != nil { if err != nil {
result.Err = model.NewAppError("SqlChannelStore.GetAll", "store.sql_channel.get_all.app_error", nil, "teamId="+teamId+", err="+err.Error(), http.StatusInternalServerError) return nil, model.NewAppError("SqlChannelStore.GetAll", "store.sql_channel.get_all.app_error", nil, "teamId="+teamId+", err="+err.Error(), http.StatusInternalServerError)
return }
}
result.Data = data return data, nil
})
} }
func (s SqlChannelStore) GetChannelsByIds(channelIds []string) ([]*model.Channel, *model.AppError) { func (s SqlChannelStore) GetChannelsByIds(channelIds []string) ([]*model.Channel, *model.AppError) {

Просмотреть файл

@@ -154,7 +154,7 @@ type ChannelStore interface {
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)
GetAll(teamId string) StoreChannel GetAll(teamId string) ([]*model.Channel, *model.AppError)
GetChannelsByIds(channelIds []string) ([]*model.Channel, *model.AppError) GetChannelsByIds(channelIds []string) ([]*model.Channel, *model.AppError)
GetForPost(postId string) (*model.Channel, *model.AppError) GetForPost(postId string) (*model.Channel, *model.AppError)
SaveMember(member *model.ChannelMember) StoreChannel SaveMember(member *model.ChannelMember) StoreChannel

Просмотреть файл

@@ -423,10 +423,9 @@ func testChannelStoreGet(t *testing.T, ss store.Store, s SqlSupplier) {
} }
} }
if r3 := <-ss.Channel().GetAll(o1.TeamId); r3.Err != nil { if channels, chanErr := ss.Channel().GetAll(o1.TeamId); chanErr != nil {
t.Fatal(r3.Err) t.Fatal(chanErr)
} else { } else {
channels := r3.Data.([]*model.Channel)
if len(channels) == 0 { if len(channels) == 0 {
t.Fatal("too little") t.Fatal("too little")
} }

Просмотреть файл

@@ -181,19 +181,28 @@ func (_m *ChannelStore) Get(id string, allowFromCache bool) (*model.Channel, *mo
} }
// GetAll provides a mock function with given fields: teamId // GetAll provides a mock function with given fields: teamId
func (_m *ChannelStore) GetAll(teamId string) store.StoreChannel { func (_m *ChannelStore) GetAll(teamId string) ([]*model.Channel, *model.AppError) {
ret := _m.Called(teamId) ret := _m.Called(teamId)
var r0 store.StoreChannel var r0 []*model.Channel
if rf, ok := ret.Get(0).(func(string) store.StoreChannel); ok { if rf, ok := ret.Get(0).(func(string) []*model.Channel); ok {
r0 = rf(teamId) r0 = rf(teamId)
} else { } else {
if ret.Get(0) != nil { if ret.Get(0) != nil {
r0 = ret.Get(0).(store.StoreChannel) r0 = ret.Get(0).([]*model.Channel)
} }
} }
return r0 var r1 *model.AppError
if rf, ok := ret.Get(1).(func(string) *model.AppError); ok {
r1 = rf(teamId)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
}
}
return r0, r1
} }
// GetAllChannelMembersForUser provides a mock function with given fields: userId, allowFromCache, includeDeleted // GetAllChannelMembersForUser provides a mock function with given fields: userId, allowFromCache, includeDeleted