GH-10968 Migrate 'Post.GetPostsBatchForIndexing' to Sync by default (#11031)
* GH-10968 Migrate 'Post.GetPostsBatchForIndexing' to Sync by default * Fix indentation and check return value
Этот коммит содержится в:
коммит произвёл
Jesús Espino
родитель
c431a686b3
Коммит
b4d444319b
@@ -1118,44 +1118,41 @@ func (s *SqlPostStore) GetPostsByIds(postIds []string) ([]*model.Post, *model.Ap
|
||||
return posts, nil
|
||||
}
|
||||
|
||||
func (s *SqlPostStore) GetPostsBatchForIndexing(startTime int64, endTime int64, limit int) store.StoreChannel {
|
||||
return store.Do(func(result *store.StoreResult) {
|
||||
var posts []*model.PostForIndexing
|
||||
_, err1 := s.GetSearchReplica().Select(&posts,
|
||||
`SELECT
|
||||
PostsQuery.*, Channels.TeamId, ParentPosts.CreateAt ParentCreateAt
|
||||
FROM (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
Posts
|
||||
WHERE
|
||||
Posts.CreateAt >= :StartTime
|
||||
AND
|
||||
Posts.CreateAt < :EndTime
|
||||
ORDER BY
|
||||
CreateAt ASC
|
||||
LIMIT
|
||||
1000
|
||||
)
|
||||
AS
|
||||
PostsQuery
|
||||
LEFT JOIN
|
||||
Channels
|
||||
ON
|
||||
PostsQuery.ChannelId = Channels.Id
|
||||
LEFT JOIN
|
||||
Posts ParentPosts
|
||||
ON
|
||||
PostsQuery.RootId = ParentPosts.Id`,
|
||||
map[string]interface{}{"StartTime": startTime, "EndTime": endTime, "NumPosts": limit})
|
||||
func (s *SqlPostStore) GetPostsBatchForIndexing(startTime int64, endTime int64, limit int) ([]*model.PostForIndexing, *model.AppError) {
|
||||
var posts []*model.PostForIndexing
|
||||
_, err := s.GetSearchReplica().Select(&posts,
|
||||
`SELECT
|
||||
PostsQuery.*, Channels.TeamId, ParentPosts.CreateAt ParentCreateAt
|
||||
FROM (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
Posts
|
||||
WHERE
|
||||
Posts.CreateAt >= :StartTime
|
||||
AND
|
||||
Posts.CreateAt < :EndTime
|
||||
ORDER BY
|
||||
CreateAt ASC
|
||||
LIMIT
|
||||
1000
|
||||
)
|
||||
AS
|
||||
PostsQuery
|
||||
LEFT JOIN
|
||||
Channels
|
||||
ON
|
||||
PostsQuery.ChannelId = Channels.Id
|
||||
LEFT JOIN
|
||||
Posts ParentPosts
|
||||
ON
|
||||
PostsQuery.RootId = ParentPosts.Id`,
|
||||
map[string]interface{}{"StartTime": startTime, "EndTime": endTime, "NumPosts": limit})
|
||||
|
||||
if err1 != nil {
|
||||
result.Err = model.NewAppError("SqlPostStore.GetPostContext", "store.sql_post.get_posts_batch_for_indexing.get.app_error", nil, err1.Error(), http.StatusInternalServerError)
|
||||
} else {
|
||||
result.Data = posts
|
||||
}
|
||||
})
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SqlPostStore.GetPostContext", "store.sql_post.get_posts_batch_for_indexing.get.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
return posts, nil
|
||||
}
|
||||
|
||||
func (s *SqlPostStore) PermanentDeleteBatch(endTime int64, limit int64) store.StoreChannel {
|
||||
|
||||
Ссылка в новой задаче
Block a user