Move Thread.GetPosts to PostStore.GetPostsByThread (#21633)

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Shota Gvinepadze
2022-11-16 13:42:26 +04:00
коммит произвёл GitHub
родитель ab5137395c
Коммит 98e685f07c
9 изменённых файлов: 97 добавлений и 97 удалений

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

@@ -1400,6 +1400,23 @@ func (s *SqlPostStore) GetPostsAfter(options model.GetPostsOptions, sanitizeOpti
return s.getPostsAround(false, options, sanitizeOptions)
}
func (s *SqlPostStore) GetPostsByThread(threadId string, since int64) ([]*model.Post, error) {
query := s.getQueryBuilder().
Select("*").
From("Posts").
Where(sq.Eq{"RootId": threadId}).
Where(sq.Eq{"DeleteAt": 0}).
Where(sq.GtOrEq{"CreateAt": since})
result := []*model.Post{}
err := s.GetReplicaX().SelectBuilder(&result, query)
if err != nil {
return nil, errors.Wrap(err, "failed to fetch thread posts")
}
return result, nil
}
func (s *SqlPostStore) getPostsAround(before bool, options model.GetPostsOptions, sanitizeOptions map[string]bool) (*model.PostList, error) {
if options.Page < 0 {
return nil, store.NewErrInvalidInput("Post", "<options.Page>", options.Page)

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

@@ -779,23 +779,6 @@ func (s *SqlThreadStore) MaintainMembership(userId, postId string, opts store.Th
return membership, err
}
func (s *SqlThreadStore) GetPosts(threadId string, since int64) ([]*model.Post, error) {
query := s.getQueryBuilder().
Select("*").
From("Posts").
Where(sq.Eq{"RootId": threadId}).
Where(sq.Eq{"DeleteAt": 0}).
Where(sq.GtOrEq{"CreateAt": since})
result := []*model.Post{}
err := s.GetReplicaX().SelectBuilder(&result, query)
if err != nil {
return nil, errors.Wrap(err, "failed to fetch thread posts")
}
return result, nil
}
// PermanentDeleteBatchForRetentionPolicies deletes a batch of records which are affected by
// the global or a granular retention policy.
// See `genericPermanentDeleteBatchForRetentionPolicies` for details.