diff options
Diffstat (limited to 'store/sqlstore/post_store.go')
-rw-r--r-- | store/sqlstore/post_store.go | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/store/sqlstore/post_store.go b/store/sqlstore/post_store.go index 9cf33888d..bc85b260e 100644 --- a/store/sqlstore/post_store.go +++ b/store/sqlstore/post_store.go @@ -1308,3 +1308,68 @@ func (s *SqlPostStore) GetMaxPostSize() store.StoreChannel { result.Data = s.maxPostSizeCached }) } + +func (s *SqlPostStore) GetParentsForExportAfter(limit int, afterId string) store.StoreChannel { + return store.Do(func(result *store.StoreResult) { + var posts []*model.PostForExport + _, err1 := s.GetSearchReplica().Select(&posts, ` + SELECT + p1.*, + Users.Username as Username, + Teams.Name as TeamName, + Channels.Name as ChannelName + FROM + Posts p1 + INNER JOIN + Channels ON p1.ChannelId = Channels.Id + INNER JOIN + Teams ON Channels.TeamId = Teams.Id + INNER JOIN + Users ON p1.UserId = Users.Id + WHERE + p1.Id > :AfterId + AND p1.ParentId = '' + AND p1.DeleteAt = 0 + AND Channels.DeleteAt = 0 + AND Teams.DeleteAt = 0 + AND Users.DeleteAt = 0 + ORDER BY + p1.Id + LIMIT + :Limit`, + map[string]interface{}{"Limit": limit, "AfterId": afterId}) + + if err1 != nil { + result.Err = model.NewAppError("SqlPostStore.GetAllAfterForExport", "store.sql_post.get_posts.app_error", nil, err1.Error(), http.StatusInternalServerError) + } else { + result.Data = posts + } + }) +} + +func (s *SqlPostStore) GetRepliesForExport(parentId string) store.StoreChannel { + return store.Do(func(result *store.StoreResult) { + var posts []*model.ReplyForExport + _, err1 := s.GetSearchReplica().Select(&posts, ` + SELECT + Posts.*, + Users.Username as Username + FROM + Posts + INNER JOIN + Users ON Posts.UserId = Users.Id + WHERE + Posts.ParentId = :ParentId + AND Posts.DeleteAt = 0 + AND Users.DeleteAt = 0 + ORDER BY + Posts.Id`, + map[string]interface{}{"ParentId": parentId}) + + if err1 != nil { + result.Err = model.NewAppError("SqlPostStore.GetAllAfterForExport", "store.sql_post.get_posts.app_error", nil, err1.Error(), http.StatusInternalServerError) + } else { + result.Data = posts + } + }) +} |