diff options
author | George Goldberg <george@gberg.me> | 2017-07-11 09:09:15 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-11 09:09:15 +0100 |
commit | 83d53ea98cf5486f89bd4280b6b5ef835da4fd22 (patch) | |
tree | 1977949d599b3ce3b023f8699854d974be4d92a8 /store/sql_post_store.go | |
parent | 0cc60abf6a33dca0d8317481f83d0eb2771f43a1 (diff) | |
download | chat-83d53ea98cf5486f89bd4280b6b5ef835da4fd22.tar.gz chat-83d53ea98cf5486f89bd4280b6b5ef835da4fd22.tar.bz2 chat-83d53ea98cf5486f89bd4280b6b5ef835da4fd22.zip |
PLT-6475: Elasticsearch Indexing Worker. (#6879)
Diffstat (limited to 'store/sql_post_store.go')
-rw-r--r-- | store/sql_post_store.go | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/store/sql_post_store.go b/store/sql_post_store.go index 6db2d5992..16142681c 100644 --- a/store/sql_post_store.go +++ b/store/sql_post_store.go @@ -1315,3 +1315,44 @@ func (s SqlPostStore) GetPostsByIds(postIds []string) StoreChannel { return storeChannel } + +func (s SqlPostStore) GetPostsBatchForIndexing(startTime int64, limit int) StoreChannel { + storeChannel := make(StoreChannel, 1) + + go func() { + result := StoreResult{} + + var posts []*model.PostForIndexing + _, err1 := s.GetSearchReplica().Select(&posts, + `(SELECT + Posts.*, + Channels.TeamId, + ParentPosts.CreateAt ParentCreateAt + FROM + Posts + LEFT JOIN + Channels + ON + Posts.ChannelId = Channels.Id + LEFT JOIN + Posts ParentPosts + ON + Posts.RootId = ParentPosts.Id + WHERE + Posts.CreateAt >= :StartTime + ORDER BY CreateAt ASC + LIMIT :NumPosts)`, + map[string]interface{}{"StartTime": startTime, "NumPosts": limit}) + + if err1 != nil { + result.Err = model.NewLocAppError("SqlPostStore.GetPostContext", "store.sql_post.get_posts_batch_for_indexing.get.app_error", nil, err1.Error()) + } else { + result.Data = posts + } + + storeChannel <- result + close(storeChannel) + }() + + return storeChannel +} |