Migrate GetAllChannels and GetAllChannelsCount from ChannelStore to r… (#14765)
* Migrate GetAllChannels and GetAllChannelsCount from ChannelStore to return plain errors * Moving i18n translations to the correct place Co-authored-by: Jesús Espino <jespinog@gmail.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
779099d1a9
Коммит
cac154e62b
@@ -931,37 +931,37 @@ func (s SqlChannelStore) GetChannels(teamId string, userId string, includeDelete
|
||||
return channels, nil
|
||||
}
|
||||
|
||||
func (s SqlChannelStore) GetAllChannels(offset, limit int, opts store.ChannelSearchOpts) (*model.ChannelListWithTeamData, *model.AppError) {
|
||||
func (s SqlChannelStore) GetAllChannels(offset, limit int, opts store.ChannelSearchOpts) (*model.ChannelListWithTeamData, error) {
|
||||
query := s.getAllChannelsQuery(opts, false)
|
||||
|
||||
query = query.OrderBy("c.DisplayName, Teams.DisplayName").Limit(uint64(limit)).Offset(uint64(offset))
|
||||
|
||||
queryString, args, err := query.ToSql()
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SqlChannelStore.GetAllChannels", "store.sql.build_query.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return nil, errors.Wrap(err, "failed to create query")
|
||||
}
|
||||
|
||||
data := &model.ChannelListWithTeamData{}
|
||||
_, err = s.GetReplica().Select(data, queryString, args...)
|
||||
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SqlChannelStore.GetAllChannels", "store.sql_channel.get_all_channels.get.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return nil, errors.Wrap(err, "failed to get all channels")
|
||||
}
|
||||
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func (s SqlChannelStore) GetAllChannelsCount(opts store.ChannelSearchOpts) (int64, *model.AppError) {
|
||||
func (s SqlChannelStore) GetAllChannelsCount(opts store.ChannelSearchOpts) (int64, error) {
|
||||
query := s.getAllChannelsQuery(opts, true)
|
||||
|
||||
queryString, args, err := query.ToSql()
|
||||
if err != nil {
|
||||
return 0, model.NewAppError("SqlChannelStore.GetAllChannelsCount", "store.sql.build_query.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return 0, errors.Wrap(err, "failed to create query")
|
||||
}
|
||||
|
||||
count, err := s.GetReplica().SelectInt(queryString, args...)
|
||||
if err != nil {
|
||||
return 0, model.NewAppError("SqlChannelStore.GetAllChannelsCount", "store.sql_channel.get_all_channels.get.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return 0, errors.Wrap(err, "failed to count all channels")
|
||||
}
|
||||
|
||||
return count, nil
|
||||
|
||||
Ссылка в новой задаче
Block a user