Migrates "Channel.GetAll" to Sync by default (#11281)
Этот коммит содержится в:
коммит произвёл
Miguel de la Cruz
родитель
a02467698c
Коммит
2ce36c2eb1
@@ -444,11 +444,9 @@ func listChannelsCmdF(command *cobra.Command, args []string) error {
|
||||
CommandPrintErrorln("Unable to find team '" + args[i] + "'")
|
||||
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] + "'")
|
||||
} else {
|
||||
channels := result.Data.([]*model.Channel)
|
||||
|
||||
for _, channel := range channels {
|
||||
if channel.DeleteAt > 0 {
|
||||
CommandPrettyPrintln(channel.Name + " (archived)")
|
||||
|
||||
@@ -1829,18 +1829,15 @@ func (s SqlChannelStore) IncrementMentionCount(channelId string, userId string)
|
||||
})
|
||||
}
|
||||
|
||||
func (s SqlChannelStore) GetAll(teamId string) store.StoreChannel {
|
||||
return store.Do(func(result *store.StoreResult) {
|
||||
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})
|
||||
func (s SqlChannelStore) GetAll(teamId string) ([]*model.Channel, *model.AppError) {
|
||||
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})
|
||||
|
||||
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
|
||||
}
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SqlChannelStore.GetAll", "store.sql_channel.get_all.app_error", nil, "teamId="+teamId+", err="+err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
result.Data = data
|
||||
})
|
||||
return data, nil
|
||||
}
|
||||
|
||||
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)
|
||||
GetChannelCounts(teamId string, userId string) (*model.ChannelCounts, *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)
|
||||
GetForPost(postId string) (*model.Channel, *model.AppError)
|
||||
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 {
|
||||
t.Fatal(r3.Err)
|
||||
if channels, chanErr := ss.Channel().GetAll(o1.TeamId); chanErr != nil {
|
||||
t.Fatal(chanErr)
|
||||
} else {
|
||||
channels := r3.Data.([]*model.Channel)
|
||||
if len(channels) == 0 {
|
||||
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
|
||||
func (_m *ChannelStore) GetAll(teamId string) store.StoreChannel {
|
||||
func (_m *ChannelStore) GetAll(teamId string) ([]*model.Channel, *model.AppError) {
|
||||
ret := _m.Called(teamId)
|
||||
|
||||
var r0 store.StoreChannel
|
||||
if rf, ok := ret.Get(0).(func(string) store.StoreChannel); ok {
|
||||
var r0 []*model.Channel
|
||||
if rf, ok := ret.Get(0).(func(string) []*model.Channel); ok {
|
||||
r0 = rf(teamId)
|
||||
} else {
|
||||
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
|
||||
|
||||
Ссылка в новой задаче
Block a user