Migration of PostStore Part 2 (#15181)
* Starting migration * Lint: remove unnecessary use of sprintf * Fix i18n * Some suggestions * Fix store layers Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
d85cec1a4e
Коммит
1ab06ffa7c
94
app/post.go
94
app/post.go
@@ -680,7 +680,12 @@ func (a *App) GetPostsEtag(channelId string) string {
|
||||
}
|
||||
|
||||
func (a *App) GetPostsSince(options model.GetPostsSinceOptions) (*model.PostList, *model.AppError) {
|
||||
return a.Srv().Store.Post().GetPostsSince(options, true)
|
||||
postList, err := a.Srv().Store.Post().GetPostsSince(options, true)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetPostsSince", "app.post.get_posts_since.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return postList, nil
|
||||
}
|
||||
|
||||
func (a *App) GetSinglePost(postId string) (*model.Post, *model.AppError) {
|
||||
@@ -717,15 +722,30 @@ func (a *App) GetPostThread(postId string, skipFetchThreads bool) (*model.PostLi
|
||||
}
|
||||
|
||||
func (a *App) GetFlaggedPosts(userId string, offset int, limit int) (*model.PostList, *model.AppError) {
|
||||
return a.Srv().Store.Post().GetFlaggedPosts(userId, offset, limit)
|
||||
postList, err := a.Srv().Store.Post().GetFlaggedPosts(userId, offset, limit)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetFlaggedPosts", "app.post.get_flagged_posts.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return postList, nil
|
||||
}
|
||||
|
||||
func (a *App) GetFlaggedPostsForTeam(userId, teamId string, offset int, limit int) (*model.PostList, *model.AppError) {
|
||||
return a.Srv().Store.Post().GetFlaggedPostsForTeam(userId, teamId, offset, limit)
|
||||
postList, err := a.Srv().Store.Post().GetFlaggedPostsForTeam(userId, teamId, offset, limit)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetFlaggedPostsForTeam", "app.post.get_flagged_posts.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return postList, nil
|
||||
}
|
||||
|
||||
func (a *App) GetFlaggedPostsForChannel(userId, channelId string, offset int, limit int) (*model.PostList, *model.AppError) {
|
||||
return a.Srv().Store.Post().GetFlaggedPostsForChannel(userId, channelId, offset, limit)
|
||||
postList, err := a.Srv().Store.Post().GetFlaggedPostsForChannel(userId, channelId, offset, limit)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetFlaggedPostsForChannel", "app.post.get_flagged_posts.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return postList, nil
|
||||
}
|
||||
|
||||
func (a *App) GetPermalinkPost(postId string, userId string) (*model.PostList, *model.AppError) {
|
||||
@@ -761,30 +781,82 @@ func (a *App) GetPermalinkPost(postId string, userId string) (*model.PostList, *
|
||||
}
|
||||
|
||||
func (a *App) GetPostsBeforePost(options model.GetPostsOptions) (*model.PostList, *model.AppError) {
|
||||
return a.Srv().Store.Post().GetPostsBefore(options)
|
||||
postList, err := a.Srv().Store.Post().GetPostsBefore(options)
|
||||
if err != nil {
|
||||
var invErr *store.ErrInvalidInput
|
||||
switch {
|
||||
case errors.As(err, &invErr):
|
||||
return nil, model.NewAppError("GetPostsBeforePost", "app.post.get_posts_around.get.app_error", nil, invErr.Error(), http.StatusBadRequest)
|
||||
default:
|
||||
return nil, model.NewAppError("GetPostsBeforePost", "app.post.get_posts_around.get.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
return postList, nil
|
||||
}
|
||||
|
||||
func (a *App) GetPostsAfterPost(options model.GetPostsOptions) (*model.PostList, *model.AppError) {
|
||||
return a.Srv().Store.Post().GetPostsAfter(options)
|
||||
postList, err := a.Srv().Store.Post().GetPostsAfter(options)
|
||||
if err != nil {
|
||||
var invErr *store.ErrInvalidInput
|
||||
switch {
|
||||
case errors.As(err, &invErr):
|
||||
return nil, model.NewAppError("GetPostsAfterPost", "app.post.get_posts_around.get.app_error", nil, invErr.Error(), http.StatusBadRequest)
|
||||
default:
|
||||
return nil, model.NewAppError("GetPostsAfterPost", "app.post.get_posts_around.get.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
return postList, nil
|
||||
}
|
||||
|
||||
func (a *App) GetPostsAroundPost(before bool, options model.GetPostsOptions) (*model.PostList, *model.AppError) {
|
||||
var postList *model.PostList
|
||||
var err error
|
||||
if before {
|
||||
return a.Srv().Store.Post().GetPostsBefore(options)
|
||||
postList, err = a.Srv().Store.Post().GetPostsBefore(options)
|
||||
} else {
|
||||
postList, err = a.Srv().Store.Post().GetPostsAfter(options)
|
||||
}
|
||||
return a.Srv().Store.Post().GetPostsAfter(options)
|
||||
|
||||
if err != nil {
|
||||
var invErr *store.ErrInvalidInput
|
||||
switch {
|
||||
case errors.As(err, &invErr):
|
||||
return nil, model.NewAppError("GetPostsAroundPost", "app.post.get_posts_around.get.app_error", nil, invErr.Error(), http.StatusBadRequest)
|
||||
default:
|
||||
return nil, model.NewAppError("GetPostsAroundPost", "app.post.get_posts_around.get.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
return postList, nil
|
||||
}
|
||||
|
||||
func (a *App) GetPostAfterTime(channelId string, time int64) (*model.Post, *model.AppError) {
|
||||
return a.Srv().Store.Post().GetPostAfterTime(channelId, time)
|
||||
post, err := a.Srv().Store.Post().GetPostAfterTime(channelId, time)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetPostAfterTime", "app.post.get_post_after_time.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return post, nil
|
||||
}
|
||||
|
||||
func (a *App) GetPostIdAfterTime(channelId string, time int64) (string, *model.AppError) {
|
||||
return a.Srv().Store.Post().GetPostIdAfterTime(channelId, time)
|
||||
postId, err := a.Srv().Store.Post().GetPostIdAfterTime(channelId, time)
|
||||
if err != nil {
|
||||
return "", model.NewAppError("GetPostIdAfterTime", "app.post.get_post_id_around.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return postId, nil
|
||||
}
|
||||
|
||||
func (a *App) GetPostIdBeforeTime(channelId string, time int64) (string, *model.AppError) {
|
||||
return a.Srv().Store.Post().GetPostIdBeforeTime(channelId, time)
|
||||
postId, err := a.Srv().Store.Post().GetPostIdBeforeTime(channelId, time)
|
||||
if err != nil {
|
||||
return "", model.NewAppError("GetPostIdBeforeTime", "app.post.get_post_id_around.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return postId, nil
|
||||
}
|
||||
|
||||
func (a *App) GetNextPostIdFromPostList(postList *model.PostList) string {
|
||||
|
||||
44
i18n/en.json
44
i18n/en.json
@@ -4458,6 +4458,26 @@
|
||||
"id": "app.post.get.app_error",
|
||||
"translation": "Unable to get the post."
|
||||
},
|
||||
{
|
||||
"id": "app.post.get_flagged_posts.app_error",
|
||||
"translation": "Unable to get the flagged posts."
|
||||
},
|
||||
{
|
||||
"id": "app.post.get_post_after_time.app_error",
|
||||
"translation": "Unable to get post after time bound."
|
||||
},
|
||||
{
|
||||
"id": "app.post.get_post_id_around.app_error",
|
||||
"translation": "Unable to get post around time bound."
|
||||
},
|
||||
{
|
||||
"id": "app.post.get_posts_around.get.app_error",
|
||||
"translation": "Unable to get the posts for the channel."
|
||||
},
|
||||
{
|
||||
"id": "app.post.get_posts_since.app_error",
|
||||
"translation": "Unable to get the posts for the channel."
|
||||
},
|
||||
{
|
||||
"id": "app.post.permanent_delete_by_channel.app_error",
|
||||
"translation": "Unable to delete the posts by channel."
|
||||
@@ -7454,10 +7474,6 @@
|
||||
"id": "store.sql_post.get_direct_posts.app_error",
|
||||
"translation": "Unable to get direct posts."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_post.get_flagged_posts.app_error",
|
||||
"translation": "Unable to get the flagged posts."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_post.get_oldest_entity_creation_time.app_error",
|
||||
"translation": "Unable to get the oldest entitiy creation time."
|
||||
@@ -7466,26 +7482,10 @@
|
||||
"id": "store.sql_post.get_parents_posts.app_error",
|
||||
"translation": "Unable to get the parent post for the channel."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_post.get_post_after_time.app_error",
|
||||
"translation": "Unable to get post after time bound."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_post.get_post_id_around.app_error",
|
||||
"translation": "Unable to get post around time bound."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_post.get_posts.app_error",
|
||||
"translation": "Limit exceeded for paging."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_post.get_posts_around.get.app_error",
|
||||
"translation": "Unable to get the posts for the channel."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_post.get_posts_around.get_parent.app_error",
|
||||
"translation": "Unable to get the parent posts for the channel."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_post.get_posts_batch_for_indexing.get.app_error",
|
||||
"translation": "Unable to get the posts batch for indexing."
|
||||
@@ -7498,10 +7498,6 @@
|
||||
"id": "store.sql_post.get_posts_created_att.app_error",
|
||||
"translation": "Unable to get the posts for the channel."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_post.get_posts_since.app_error",
|
||||
"translation": "Unable to get the posts for the channel."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_post.get_root_posts.app_error",
|
||||
"translation": "Unable to get the posts for the channel."
|
||||
|
||||
@@ -79,7 +79,7 @@ func (s LocalCachePostStore) GetEtag(channelId string, allowFromCache bool) stri
|
||||
return result
|
||||
}
|
||||
|
||||
func (s LocalCachePostStore) GetPostsSince(options model.GetPostsSinceOptions, allowFromCache bool) (*model.PostList, *model.AppError) {
|
||||
func (s LocalCachePostStore) GetPostsSince(options model.GetPostsSinceOptions, allowFromCache bool) (*model.PostList, error) {
|
||||
if allowFromCache {
|
||||
// If the last post in the channel's time is less than or equal to the time we are getting posts since,
|
||||
// we can safely return no posts.
|
||||
|
||||
@@ -4827,7 +4827,7 @@ func (s *OpenTracingLayerPostStore) GetEtag(channelId string, allowFromCache boo
|
||||
return result
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerPostStore) GetFlaggedPosts(userId string, offset int, limit int) (*model.PostList, *model.AppError) {
|
||||
func (s *OpenTracingLayerPostStore) GetFlaggedPosts(userId string, offset int, limit int) (*model.PostList, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "PostStore.GetFlaggedPosts")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -4845,7 +4845,7 @@ func (s *OpenTracingLayerPostStore) GetFlaggedPosts(userId string, offset int, l
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerPostStore) GetFlaggedPostsForChannel(userId string, channelId string, offset int, limit int) (*model.PostList, *model.AppError) {
|
||||
func (s *OpenTracingLayerPostStore) GetFlaggedPostsForChannel(userId string, channelId string, offset int, limit int) (*model.PostList, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "PostStore.GetFlaggedPostsForChannel")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -4863,7 +4863,7 @@ func (s *OpenTracingLayerPostStore) GetFlaggedPostsForChannel(userId string, cha
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerPostStore) GetFlaggedPostsForTeam(userId string, teamId string, offset int, limit int) (*model.PostList, *model.AppError) {
|
||||
func (s *OpenTracingLayerPostStore) GetFlaggedPostsForTeam(userId string, teamId string, offset int, limit int) (*model.PostList, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "PostStore.GetFlaggedPostsForTeam")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -4956,7 +4956,7 @@ func (s *OpenTracingLayerPostStore) GetParentsForExportAfter(limit int, afterId
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerPostStore) GetPostAfterTime(channelId string, time int64) (*model.Post, *model.AppError) {
|
||||
func (s *OpenTracingLayerPostStore) GetPostAfterTime(channelId string, time int64) (*model.Post, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "PostStore.GetPostAfterTime")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -4974,7 +4974,7 @@ func (s *OpenTracingLayerPostStore) GetPostAfterTime(channelId string, time int6
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerPostStore) GetPostIdAfterTime(channelId string, time int64) (string, *model.AppError) {
|
||||
func (s *OpenTracingLayerPostStore) GetPostIdAfterTime(channelId string, time int64) (string, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "PostStore.GetPostIdAfterTime")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -4992,7 +4992,7 @@ func (s *OpenTracingLayerPostStore) GetPostIdAfterTime(channelId string, time in
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerPostStore) GetPostIdBeforeTime(channelId string, time int64) (string, *model.AppError) {
|
||||
func (s *OpenTracingLayerPostStore) GetPostIdBeforeTime(channelId string, time int64) (string, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "PostStore.GetPostIdBeforeTime")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -5028,7 +5028,7 @@ func (s *OpenTracingLayerPostStore) GetPosts(options model.GetPostsOptions, allo
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerPostStore) GetPostsAfter(options model.GetPostsOptions) (*model.PostList, *model.AppError) {
|
||||
func (s *OpenTracingLayerPostStore) GetPostsAfter(options model.GetPostsOptions) (*model.PostList, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "PostStore.GetPostsAfter")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -5064,7 +5064,7 @@ func (s *OpenTracingLayerPostStore) GetPostsBatchForIndexing(startTime int64, en
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerPostStore) GetPostsBefore(options model.GetPostsOptions) (*model.PostList, *model.AppError) {
|
||||
func (s *OpenTracingLayerPostStore) GetPostsBefore(options model.GetPostsOptions) (*model.PostList, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "PostStore.GetPostsBefore")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -5118,7 +5118,7 @@ func (s *OpenTracingLayerPostStore) GetPostsCreatedAt(channelId string, time int
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerPostStore) GetPostsSince(options model.GetPostsSinceOptions, allowFromCache bool) (*model.PostList, *model.AppError) {
|
||||
func (s *OpenTracingLayerPostStore) GetPostsSince(options model.GetPostsSinceOptions, allowFromCache bool) (*model.PostList, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "PostStore.GetPostsSince")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
|
||||
@@ -3762,21 +3762,63 @@ func (s *RetryLayerPostStore) GetEtag(channelId string, allowFromCache bool) str
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerPostStore) GetFlaggedPosts(userId string, offset int, limit int) (*model.PostList, *model.AppError) {
|
||||
func (s *RetryLayerPostStore) GetFlaggedPosts(userId string, offset int, limit int) (*model.PostList, error) {
|
||||
|
||||
return s.PostStore.GetFlaggedPosts(userId, offset, limit)
|
||||
tries := 0
|
||||
for {
|
||||
result, err := s.PostStore.GetFlaggedPosts(userId, offset, limit)
|
||||
if err == nil {
|
||||
return result, nil
|
||||
}
|
||||
if !isRepeatableError(err) {
|
||||
return result, err
|
||||
}
|
||||
tries++
|
||||
if tries >= 3 {
|
||||
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
|
||||
return result, err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerPostStore) GetFlaggedPostsForChannel(userId string, channelId string, offset int, limit int) (*model.PostList, *model.AppError) {
|
||||
func (s *RetryLayerPostStore) GetFlaggedPostsForChannel(userId string, channelId string, offset int, limit int) (*model.PostList, error) {
|
||||
|
||||
return s.PostStore.GetFlaggedPostsForChannel(userId, channelId, offset, limit)
|
||||
tries := 0
|
||||
for {
|
||||
result, err := s.PostStore.GetFlaggedPostsForChannel(userId, channelId, offset, limit)
|
||||
if err == nil {
|
||||
return result, nil
|
||||
}
|
||||
if !isRepeatableError(err) {
|
||||
return result, err
|
||||
}
|
||||
tries++
|
||||
if tries >= 3 {
|
||||
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
|
||||
return result, err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerPostStore) GetFlaggedPostsForTeam(userId string, teamId string, offset int, limit int) (*model.PostList, *model.AppError) {
|
||||
func (s *RetryLayerPostStore) GetFlaggedPostsForTeam(userId string, teamId string, offset int, limit int) (*model.PostList, error) {
|
||||
|
||||
return s.PostStore.GetFlaggedPostsForTeam(userId, teamId, offset, limit)
|
||||
tries := 0
|
||||
for {
|
||||
result, err := s.PostStore.GetFlaggedPostsForTeam(userId, teamId, offset, limit)
|
||||
if err == nil {
|
||||
return result, nil
|
||||
}
|
||||
if !isRepeatableError(err) {
|
||||
return result, err
|
||||
}
|
||||
tries++
|
||||
if tries >= 3 {
|
||||
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
|
||||
return result, err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3804,21 +3846,63 @@ func (s *RetryLayerPostStore) GetParentsForExportAfter(limit int, afterId string
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerPostStore) GetPostAfterTime(channelId string, time int64) (*model.Post, *model.AppError) {
|
||||
func (s *RetryLayerPostStore) GetPostAfterTime(channelId string, time int64) (*model.Post, error) {
|
||||
|
||||
return s.PostStore.GetPostAfterTime(channelId, time)
|
||||
tries := 0
|
||||
for {
|
||||
result, err := s.PostStore.GetPostAfterTime(channelId, time)
|
||||
if err == nil {
|
||||
return result, nil
|
||||
}
|
||||
if !isRepeatableError(err) {
|
||||
return result, err
|
||||
}
|
||||
tries++
|
||||
if tries >= 3 {
|
||||
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
|
||||
return result, err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerPostStore) GetPostIdAfterTime(channelId string, time int64) (string, *model.AppError) {
|
||||
func (s *RetryLayerPostStore) GetPostIdAfterTime(channelId string, time int64) (string, error) {
|
||||
|
||||
return s.PostStore.GetPostIdAfterTime(channelId, time)
|
||||
tries := 0
|
||||
for {
|
||||
result, err := s.PostStore.GetPostIdAfterTime(channelId, time)
|
||||
if err == nil {
|
||||
return result, nil
|
||||
}
|
||||
if !isRepeatableError(err) {
|
||||
return result, err
|
||||
}
|
||||
tries++
|
||||
if tries >= 3 {
|
||||
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
|
||||
return result, err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerPostStore) GetPostIdBeforeTime(channelId string, time int64) (string, *model.AppError) {
|
||||
func (s *RetryLayerPostStore) GetPostIdBeforeTime(channelId string, time int64) (string, error) {
|
||||
|
||||
return s.PostStore.GetPostIdBeforeTime(channelId, time)
|
||||
tries := 0
|
||||
for {
|
||||
result, err := s.PostStore.GetPostIdBeforeTime(channelId, time)
|
||||
if err == nil {
|
||||
return result, nil
|
||||
}
|
||||
if !isRepeatableError(err) {
|
||||
return result, err
|
||||
}
|
||||
tries++
|
||||
if tries >= 3 {
|
||||
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
|
||||
return result, err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3828,9 +3912,23 @@ func (s *RetryLayerPostStore) GetPosts(options model.GetPostsOptions, allowFromC
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerPostStore) GetPostsAfter(options model.GetPostsOptions) (*model.PostList, *model.AppError) {
|
||||
func (s *RetryLayerPostStore) GetPostsAfter(options model.GetPostsOptions) (*model.PostList, error) {
|
||||
|
||||
return s.PostStore.GetPostsAfter(options)
|
||||
tries := 0
|
||||
for {
|
||||
result, err := s.PostStore.GetPostsAfter(options)
|
||||
if err == nil {
|
||||
return result, nil
|
||||
}
|
||||
if !isRepeatableError(err) {
|
||||
return result, err
|
||||
}
|
||||
tries++
|
||||
if tries >= 3 {
|
||||
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
|
||||
return result, err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3840,9 +3938,23 @@ func (s *RetryLayerPostStore) GetPostsBatchForIndexing(startTime int64, endTime
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerPostStore) GetPostsBefore(options model.GetPostsOptions) (*model.PostList, *model.AppError) {
|
||||
func (s *RetryLayerPostStore) GetPostsBefore(options model.GetPostsOptions) (*model.PostList, error) {
|
||||
|
||||
return s.PostStore.GetPostsBefore(options)
|
||||
tries := 0
|
||||
for {
|
||||
result, err := s.PostStore.GetPostsBefore(options)
|
||||
if err == nil {
|
||||
return result, nil
|
||||
}
|
||||
if !isRepeatableError(err) {
|
||||
return result, err
|
||||
}
|
||||
tries++
|
||||
if tries >= 3 {
|
||||
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
|
||||
return result, err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3858,9 +3970,23 @@ func (s *RetryLayerPostStore) GetPostsCreatedAt(channelId string, time int64) ([
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerPostStore) GetPostsSince(options model.GetPostsSinceOptions, allowFromCache bool) (*model.PostList, *model.AppError) {
|
||||
func (s *RetryLayerPostStore) GetPostsSince(options model.GetPostsSinceOptions, allowFromCache bool) (*model.PostList, error) {
|
||||
|
||||
return s.PostStore.GetPostsSince(options, allowFromCache)
|
||||
tries := 0
|
||||
for {
|
||||
result, err := s.PostStore.GetPostsSince(options, allowFromCache)
|
||||
if err == nil {
|
||||
return result, nil
|
||||
}
|
||||
if !isRepeatableError(err) {
|
||||
return result, err
|
||||
}
|
||||
tries++
|
||||
if tries >= 3 {
|
||||
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
|
||||
return result, err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -314,12 +314,12 @@ func (s *SqlPostStore) Overwrite(post *model.Post) (*model.Post, *model.AppError
|
||||
return posts[0], nil
|
||||
}
|
||||
|
||||
func (s *SqlPostStore) GetFlaggedPosts(userId string, offset int, limit int) (*model.PostList, *model.AppError) {
|
||||
func (s *SqlPostStore) GetFlaggedPosts(userId string, offset int, limit int) (*model.PostList, error) {
|
||||
pl := model.NewPostList()
|
||||
|
||||
var posts []*model.Post
|
||||
if _, err := s.GetReplica().Select(&posts, "SELECT *, (SELECT count(Posts.Id) FROM Posts WHERE Posts.RootId = (CASE WHEN p.RootId = '' THEN p.Id ELSE p.RootId END) AND Posts.DeleteAt = 0) as ReplyCount FROM Posts p WHERE Id IN (SELECT Name FROM Preferences WHERE UserId = :UserId AND Category = :Category) AND DeleteAt = 0 ORDER BY CreateAt DESC LIMIT :Limit OFFSET :Offset", map[string]interface{}{"UserId": userId, "Category": model.PREFERENCE_CATEGORY_FLAGGED_POST, "Offset": offset, "Limit": limit}); err != nil {
|
||||
return nil, model.NewAppError("SqlPostStore.GetFlaggedPosts", "store.sql_post.get_flagged_posts.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return nil, errors.Wrap(err, "failed to find Posts")
|
||||
}
|
||||
|
||||
for _, post := range posts {
|
||||
@@ -330,7 +330,7 @@ func (s *SqlPostStore) GetFlaggedPosts(userId string, offset int, limit int) (*m
|
||||
return pl, nil
|
||||
}
|
||||
|
||||
func (s *SqlPostStore) GetFlaggedPostsForTeam(userId, teamId string, offset int, limit int) (*model.PostList, *model.AppError) {
|
||||
func (s *SqlPostStore) GetFlaggedPostsForTeam(userId, teamId string, offset int, limit int) (*model.PostList, error) {
|
||||
pl := model.NewPostList()
|
||||
|
||||
var posts []*model.Post
|
||||
@@ -362,7 +362,7 @@ func (s *SqlPostStore) GetFlaggedPostsForTeam(userId, teamId string, offset int,
|
||||
LIMIT :Limit OFFSET :Offset`
|
||||
|
||||
if _, err := s.GetReplica().Select(&posts, query, map[string]interface{}{"UserId": userId, "Category": model.PREFERENCE_CATEGORY_FLAGGED_POST, "Offset": offset, "Limit": limit, "TeamId": teamId}); err != nil {
|
||||
return nil, model.NewAppError("SqlPostStore.GetFlaggedPostsForTeam", "store.sql_post.get_flagged_posts.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return nil, errors.Wrap(err, "failed to find Posts")
|
||||
}
|
||||
|
||||
for _, post := range posts {
|
||||
@@ -373,7 +373,7 @@ func (s *SqlPostStore) GetFlaggedPostsForTeam(userId, teamId string, offset int,
|
||||
return pl, nil
|
||||
}
|
||||
|
||||
func (s *SqlPostStore) GetFlaggedPostsForChannel(userId, channelId string, offset int, limit int) (*model.PostList, *model.AppError) {
|
||||
func (s *SqlPostStore) GetFlaggedPostsForChannel(userId, channelId string, offset int, limit int) (*model.PostList, error) {
|
||||
pl := model.NewPostList()
|
||||
|
||||
var posts []*model.Post
|
||||
@@ -389,7 +389,7 @@ func (s *SqlPostStore) GetFlaggedPostsForChannel(userId, channelId string, offse
|
||||
LIMIT :Limit OFFSET :Offset`
|
||||
|
||||
if _, err := s.GetReplica().Select(&posts, query, map[string]interface{}{"UserId": userId, "Category": model.PREFERENCE_CATEGORY_FLAGGED_POST, "ChannelId": channelId, "Offset": offset, "Limit": limit}); err != nil {
|
||||
return nil, model.NewAppError("SqlPostStore.GetFlaggedPostsForChannel", "store.sql_post.get_flagged_posts.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return nil, errors.Wrap(err, "failed to find Posts")
|
||||
}
|
||||
for _, post := range posts {
|
||||
pl.AddPost(post)
|
||||
@@ -606,7 +606,7 @@ func (s *SqlPostStore) GetPosts(options model.GetPostsOptions, _ bool) (*model.P
|
||||
return list, err
|
||||
}
|
||||
|
||||
func (s *SqlPostStore) GetPostsSince(options model.GetPostsSinceOptions, allowFromCache bool) (*model.PostList, *model.AppError) {
|
||||
func (s *SqlPostStore) GetPostsSince(options model.GetPostsSinceOptions, allowFromCache bool) (*model.PostList, error) {
|
||||
var posts []*model.Post
|
||||
|
||||
replyCountQuery1 := ""
|
||||
@@ -677,7 +677,7 @@ func (s *SqlPostStore) GetPostsSince(options model.GetPostsSinceOptions, allowFr
|
||||
_, err := s.GetReplica().Select(&posts, query, map[string]interface{}{"ChannelId": options.ChannelId, "Time": options.Time})
|
||||
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SqlPostStore.GetPostsSince", "store.sql_post.get_posts_since.app_error", nil, "channelId="+options.ChannelId+err.Error(), http.StatusInternalServerError)
|
||||
return nil, errors.Wrapf(err, "failed to find Posts with channelId=%s", options.ChannelId)
|
||||
}
|
||||
|
||||
list := model.NewPostList()
|
||||
@@ -692,18 +692,21 @@ func (s *SqlPostStore) GetPostsSince(options model.GetPostsSinceOptions, allowFr
|
||||
return list, nil
|
||||
}
|
||||
|
||||
func (s *SqlPostStore) GetPostsBefore(options model.GetPostsOptions) (*model.PostList, *model.AppError) {
|
||||
func (s *SqlPostStore) GetPostsBefore(options model.GetPostsOptions) (*model.PostList, error) {
|
||||
return s.getPostsAround(true, options)
|
||||
}
|
||||
|
||||
func (s *SqlPostStore) GetPostsAfter(options model.GetPostsOptions) (*model.PostList, *model.AppError) {
|
||||
func (s *SqlPostStore) GetPostsAfter(options model.GetPostsOptions) (*model.PostList, error) {
|
||||
return s.getPostsAround(false, options)
|
||||
}
|
||||
|
||||
func (s *SqlPostStore) getPostsAround(before bool, options model.GetPostsOptions) (*model.PostList, *model.AppError) {
|
||||
if options.Page < 0 || options.PerPage < 0 {
|
||||
return nil, model.NewAppError("SqlPostStore.GetPostContext", "store.sql_post.get_posts_around.get.app_error", nil,
|
||||
fmt.Sprintf("Page=%d and PerPage=%d must be non-negative", options.Page, options.PerPage), http.StatusBadRequest)
|
||||
func (s *SqlPostStore) getPostsAround(before bool, options model.GetPostsOptions) (*model.PostList, error) {
|
||||
if options.Page < 0 {
|
||||
return nil, store.NewErrInvalidInput("Post", "<options.Page>", options.Page)
|
||||
}
|
||||
|
||||
if options.PerPage < 0 {
|
||||
return nil, store.NewErrInvalidInput("Post", "<options.PerPage>", options.PerPage)
|
||||
}
|
||||
|
||||
offset := options.Page * options.PerPage
|
||||
@@ -744,11 +747,11 @@ func (s *SqlPostStore) getPostsAround(before bool, options model.GetPostsOptions
|
||||
|
||||
queryString, args, err := query.ToSql()
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SqlPostStore.GetPostContext", "store.sql_post.get_posts_around.get.app_error", nil, "channelId="+options.ChannelId+err.Error(), http.StatusInternalServerError)
|
||||
return nil, errors.Wrap(err, "post_tosql")
|
||||
}
|
||||
_, err = s.GetMaster().Select(&posts, queryString, args...)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SqlPostStore.GetPostContext", "store.sql_post.get_posts_around.get.app_error", nil, "channelId="+options.ChannelId+err.Error(), http.StatusInternalServerError)
|
||||
return nil, errors.Wrapf(err, "failed to find Posts with channelId=%s", options.ChannelId)
|
||||
}
|
||||
|
||||
if len(posts) > 0 {
|
||||
@@ -779,11 +782,11 @@ func (s *SqlPostStore) getPostsAround(before bool, options model.GetPostsOptions
|
||||
rootQueryString, rootArgs, err := rootQuery.ToSql()
|
||||
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SqlPostStore.GetPostContext", "store.sql_post.get_posts_around.get_parent.app_error", nil, "channelId="+options.ChannelId+err.Error(), http.StatusInternalServerError)
|
||||
return nil, errors.Wrap(err, "post_tosql")
|
||||
}
|
||||
_, err = s.GetMaster().Select(&parents, rootQueryString, rootArgs...)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SqlPostStore.GetPostContext", "store.sql_post.get_posts_around.get_parent.app_error", nil, "channelId="+options.ChannelId+err.Error(), http.StatusInternalServerError)
|
||||
return nil, errors.Wrapf(err, "failed to find Posts with channelId=%s", options.ChannelId)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -810,15 +813,15 @@ func (s *SqlPostStore) getPostsAround(before bool, options model.GetPostsOptions
|
||||
return list, nil
|
||||
}
|
||||
|
||||
func (s *SqlPostStore) GetPostIdBeforeTime(channelId string, time int64) (string, *model.AppError) {
|
||||
func (s *SqlPostStore) GetPostIdBeforeTime(channelId string, time int64) (string, error) {
|
||||
return s.getPostIdAroundTime(channelId, time, true)
|
||||
}
|
||||
|
||||
func (s *SqlPostStore) GetPostIdAfterTime(channelId string, time int64) (string, *model.AppError) {
|
||||
func (s *SqlPostStore) GetPostIdAfterTime(channelId string, time int64) (string, error) {
|
||||
return s.getPostIdAroundTime(channelId, time, false)
|
||||
}
|
||||
|
||||
func (s *SqlPostStore) getPostIdAroundTime(channelId string, time int64, before bool) (string, *model.AppError) {
|
||||
func (s *SqlPostStore) getPostIdAroundTime(channelId string, time int64, before bool) (string, error) {
|
||||
var direction sq.Sqlizer
|
||||
var sort string
|
||||
if before {
|
||||
@@ -853,20 +856,20 @@ func (s *SqlPostStore) getPostIdAroundTime(channelId string, time int64, before
|
||||
|
||||
queryString, args, err := query.ToSql()
|
||||
if err != nil {
|
||||
return "", model.NewAppError("SqlPostStore.getPostIdAroundTime", "store.sql_post.get_post_id_around.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return "", errors.Wrap(err, "post_tosql")
|
||||
}
|
||||
|
||||
var postId string
|
||||
if err := s.GetMaster().SelectOne(&postId, queryString, args...); err != nil {
|
||||
if err != sql.ErrNoRows {
|
||||
return "", model.NewAppError("SqlPostStore.getPostIdAroundTime", "store.sql_post.get_post_id_around.app_error", nil, "channelId="+channelId+err.Error(), http.StatusInternalServerError)
|
||||
return "", errors.Wrapf(err, "failed to get Post id with channelId=%s", channelId)
|
||||
}
|
||||
}
|
||||
|
||||
return postId, nil
|
||||
}
|
||||
|
||||
func (s *SqlPostStore) GetPostAfterTime(channelId string, time int64) (*model.Post, *model.AppError) {
|
||||
func (s *SqlPostStore) GetPostAfterTime(channelId string, time int64) (*model.Post, error) {
|
||||
table := "Posts"
|
||||
// We force MySQL to use the right index to prevent it from accidentally
|
||||
// using the index_merge_intersection optimization.
|
||||
@@ -891,13 +894,13 @@ func (s *SqlPostStore) GetPostAfterTime(channelId string, time int64) (*model.Po
|
||||
|
||||
queryString, args, err := query.ToSql()
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SqlPostStore.GetPostAfterTime", "store.sql_post.get_post_after_time.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return nil, errors.Wrap(err, "post_tosql")
|
||||
}
|
||||
|
||||
var post *model.Post
|
||||
if err := s.GetMaster().SelectOne(&post, queryString, args...); err != nil {
|
||||
if err != sql.ErrNoRows {
|
||||
return nil, model.NewAppError("SqlPostStore.GetPostAfterTime", "store.sql_post.get_post_after_time.app_error", nil, "channelId="+channelId+err.Error(), http.StatusInternalServerError)
|
||||
return nil, errors.Wrapf(err, "failed to get Post with channelId=%s", channelId)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -254,16 +254,16 @@ type PostStore interface {
|
||||
PermanentDeleteByUser(userId string) error
|
||||
PermanentDeleteByChannel(channelId string) error
|
||||
GetPosts(options model.GetPostsOptions, allowFromCache bool) (*model.PostList, *model.AppError)
|
||||
GetFlaggedPosts(userId string, offset int, limit int) (*model.PostList, *model.AppError)
|
||||
GetFlaggedPosts(userId string, offset int, limit int) (*model.PostList, error)
|
||||
// @openTracingParams userId, teamId, offset, limit
|
||||
GetFlaggedPostsForTeam(userId, teamId string, offset int, limit int) (*model.PostList, *model.AppError)
|
||||
GetFlaggedPostsForChannel(userId, channelId string, offset int, limit int) (*model.PostList, *model.AppError)
|
||||
GetPostsBefore(options model.GetPostsOptions) (*model.PostList, *model.AppError)
|
||||
GetPostsAfter(options model.GetPostsOptions) (*model.PostList, *model.AppError)
|
||||
GetPostsSince(options model.GetPostsSinceOptions, allowFromCache bool) (*model.PostList, *model.AppError)
|
||||
GetPostAfterTime(channelId string, time int64) (*model.Post, *model.AppError)
|
||||
GetPostIdAfterTime(channelId string, time int64) (string, *model.AppError)
|
||||
GetPostIdBeforeTime(channelId string, time int64) (string, *model.AppError)
|
||||
GetFlaggedPostsForTeam(userId, teamId string, offset int, limit int) (*model.PostList, error)
|
||||
GetFlaggedPostsForChannel(userId, channelId string, offset int, limit int) (*model.PostList, error)
|
||||
GetPostsBefore(options model.GetPostsOptions) (*model.PostList, error)
|
||||
GetPostsAfter(options model.GetPostsOptions) (*model.PostList, error)
|
||||
GetPostsSince(options model.GetPostsSinceOptions, allowFromCache bool) (*model.PostList, error)
|
||||
GetPostAfterTime(channelId string, time int64) (*model.Post, error)
|
||||
GetPostIdAfterTime(channelId string, time int64) (string, error)
|
||||
GetPostIdBeforeTime(channelId string, time int64) (string, error)
|
||||
GetEtag(channelId string, allowFromCache bool) string
|
||||
Search(teamId string, userId string, params *model.SearchParams) (*model.PostList, *model.AppError)
|
||||
AnalyticsUserCountsWithPostsByDay(teamId string) (model.AnalyticsRows, *model.AppError)
|
||||
|
||||
@@ -169,7 +169,7 @@ func (_m *PostStore) GetEtag(channelId string, allowFromCache bool) string {
|
||||
}
|
||||
|
||||
// GetFlaggedPosts provides a mock function with given fields: userId, offset, limit
|
||||
func (_m *PostStore) GetFlaggedPosts(userId string, offset int, limit int) (*model.PostList, *model.AppError) {
|
||||
func (_m *PostStore) GetFlaggedPosts(userId string, offset int, limit int) (*model.PostList, error) {
|
||||
ret := _m.Called(userId, offset, limit)
|
||||
|
||||
var r0 *model.PostList
|
||||
@@ -181,20 +181,18 @@ func (_m *PostStore) GetFlaggedPosts(userId string, offset int, limit int) (*mod
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(string, int, int) *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(string, int, int) error); ok {
|
||||
r1 = rf(userId, offset, limit)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetFlaggedPostsForChannel provides a mock function with given fields: userId, channelId, offset, limit
|
||||
func (_m *PostStore) GetFlaggedPostsForChannel(userId string, channelId string, offset int, limit int) (*model.PostList, *model.AppError) {
|
||||
func (_m *PostStore) GetFlaggedPostsForChannel(userId string, channelId string, offset int, limit int) (*model.PostList, error) {
|
||||
ret := _m.Called(userId, channelId, offset, limit)
|
||||
|
||||
var r0 *model.PostList
|
||||
@@ -206,20 +204,18 @@ func (_m *PostStore) GetFlaggedPostsForChannel(userId string, channelId string,
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(string, string, int, int) *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(string, string, int, int) error); ok {
|
||||
r1 = rf(userId, channelId, offset, limit)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetFlaggedPostsForTeam provides a mock function with given fields: userId, teamId, offset, limit
|
||||
func (_m *PostStore) GetFlaggedPostsForTeam(userId string, teamId string, offset int, limit int) (*model.PostList, *model.AppError) {
|
||||
func (_m *PostStore) GetFlaggedPostsForTeam(userId string, teamId string, offset int, limit int) (*model.PostList, error) {
|
||||
ret := _m.Called(userId, teamId, offset, limit)
|
||||
|
||||
var r0 *model.PostList
|
||||
@@ -231,13 +227,11 @@ func (_m *PostStore) GetFlaggedPostsForTeam(userId string, teamId string, offset
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(string, string, int, int) *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(string, string, int, int) error); ok {
|
||||
r1 = rf(userId, teamId, offset, limit)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
@@ -331,7 +325,7 @@ func (_m *PostStore) GetParentsForExportAfter(limit int, afterId string) ([]*mod
|
||||
}
|
||||
|
||||
// GetPostAfterTime provides a mock function with given fields: channelId, time
|
||||
func (_m *PostStore) GetPostAfterTime(channelId string, time int64) (*model.Post, *model.AppError) {
|
||||
func (_m *PostStore) GetPostAfterTime(channelId string, time int64) (*model.Post, error) {
|
||||
ret := _m.Called(channelId, time)
|
||||
|
||||
var r0 *model.Post
|
||||
@@ -343,20 +337,18 @@ func (_m *PostStore) GetPostAfterTime(channelId string, time int64) (*model.Post
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(string, int64) *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(string, int64) error); ok {
|
||||
r1 = rf(channelId, time)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetPostIdAfterTime provides a mock function with given fields: channelId, time
|
||||
func (_m *PostStore) GetPostIdAfterTime(channelId string, time int64) (string, *model.AppError) {
|
||||
func (_m *PostStore) GetPostIdAfterTime(channelId string, time int64) (string, error) {
|
||||
ret := _m.Called(channelId, time)
|
||||
|
||||
var r0 string
|
||||
@@ -366,20 +358,18 @@ func (_m *PostStore) GetPostIdAfterTime(channelId string, time int64) (string, *
|
||||
r0 = ret.Get(0).(string)
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(string, int64) *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(string, int64) error); ok {
|
||||
r1 = rf(channelId, time)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetPostIdBeforeTime provides a mock function with given fields: channelId, time
|
||||
func (_m *PostStore) GetPostIdBeforeTime(channelId string, time int64) (string, *model.AppError) {
|
||||
func (_m *PostStore) GetPostIdBeforeTime(channelId string, time int64) (string, error) {
|
||||
ret := _m.Called(channelId, time)
|
||||
|
||||
var r0 string
|
||||
@@ -389,13 +379,11 @@ func (_m *PostStore) GetPostIdBeforeTime(channelId string, time int64) (string,
|
||||
r0 = ret.Get(0).(string)
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(string, int64) *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(string, int64) error); ok {
|
||||
r1 = rf(channelId, time)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
@@ -427,7 +415,7 @@ func (_m *PostStore) GetPosts(options model.GetPostsOptions, allowFromCache bool
|
||||
}
|
||||
|
||||
// GetPostsAfter provides a mock function with given fields: options
|
||||
func (_m *PostStore) GetPostsAfter(options model.GetPostsOptions) (*model.PostList, *model.AppError) {
|
||||
func (_m *PostStore) GetPostsAfter(options model.GetPostsOptions) (*model.PostList, error) {
|
||||
ret := _m.Called(options)
|
||||
|
||||
var r0 *model.PostList
|
||||
@@ -439,13 +427,11 @@ func (_m *PostStore) GetPostsAfter(options model.GetPostsOptions) (*model.PostLi
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(model.GetPostsOptions) *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(model.GetPostsOptions) error); ok {
|
||||
r1 = rf(options)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
@@ -477,7 +463,7 @@ func (_m *PostStore) GetPostsBatchForIndexing(startTime int64, endTime int64, li
|
||||
}
|
||||
|
||||
// GetPostsBefore provides a mock function with given fields: options
|
||||
func (_m *PostStore) GetPostsBefore(options model.GetPostsOptions) (*model.PostList, *model.AppError) {
|
||||
func (_m *PostStore) GetPostsBefore(options model.GetPostsOptions) (*model.PostList, error) {
|
||||
ret := _m.Called(options)
|
||||
|
||||
var r0 *model.PostList
|
||||
@@ -489,13 +475,11 @@ func (_m *PostStore) GetPostsBefore(options model.GetPostsOptions) (*model.PostL
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(model.GetPostsOptions) *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(model.GetPostsOptions) error); ok {
|
||||
r1 = rf(options)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
@@ -552,7 +536,7 @@ func (_m *PostStore) GetPostsCreatedAt(channelId string, time int64) ([]*model.P
|
||||
}
|
||||
|
||||
// GetPostsSince provides a mock function with given fields: options, allowFromCache
|
||||
func (_m *PostStore) GetPostsSince(options model.GetPostsSinceOptions, allowFromCache bool) (*model.PostList, *model.AppError) {
|
||||
func (_m *PostStore) GetPostsSince(options model.GetPostsSinceOptions, allowFromCache bool) (*model.PostList, error) {
|
||||
ret := _m.Called(options, allowFromCache)
|
||||
|
||||
var r0 *model.PostList
|
||||
@@ -564,13 +548,11 @@ func (_m *PostStore) GetPostsSince(options model.GetPostsSinceOptions, allowFrom
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(model.GetPostsSinceOptions, bool) *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(model.GetPostsSinceOptions, bool) error); ok {
|
||||
r1 = rf(options, allowFromCache)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
|
||||
@@ -5,7 +5,6 @@ package storetest
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"sort"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -898,12 +897,12 @@ func testPostStoreGetPostsBeforeAfter(t *testing.T, ss store.Store) {
|
||||
postList, err := ss.Post().GetPostsAfter(model.GetPostsOptions{ChannelId: channelId, PostId: posts[0].Id, Page: 0, PerPage: -1})
|
||||
assert.Nil(t, postList)
|
||||
assert.Error(t, err)
|
||||
assert.Equal(t, http.StatusBadRequest, err.StatusCode)
|
||||
assert.IsType(t, &store.ErrInvalidInput{}, err)
|
||||
|
||||
postList, err = ss.Post().GetPostsAfter(model.GetPostsOptions{ChannelId: channelId, PostId: posts[0].Id, Page: -1, PerPage: 10})
|
||||
assert.Nil(t, postList)
|
||||
assert.Error(t, err)
|
||||
assert.Equal(t, http.StatusBadRequest, err.StatusCode)
|
||||
assert.IsType(t, &store.ErrInvalidInput{}, err)
|
||||
})
|
||||
|
||||
t.Run("should not return anything before the first post", func(t *testing.T) {
|
||||
|
||||
@@ -4382,7 +4382,7 @@ func (s *TimerLayerPostStore) GetEtag(channelId string, allowFromCache bool) str
|
||||
return result
|
||||
}
|
||||
|
||||
func (s *TimerLayerPostStore) GetFlaggedPosts(userId string, offset int, limit int) (*model.PostList, *model.AppError) {
|
||||
func (s *TimerLayerPostStore) GetFlaggedPosts(userId string, offset int, limit int) (*model.PostList, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.PostStore.GetFlaggedPosts(userId, offset, limit)
|
||||
@@ -4398,7 +4398,7 @@ func (s *TimerLayerPostStore) GetFlaggedPosts(userId string, offset int, limit i
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerPostStore) GetFlaggedPostsForChannel(userId string, channelId string, offset int, limit int) (*model.PostList, *model.AppError) {
|
||||
func (s *TimerLayerPostStore) GetFlaggedPostsForChannel(userId string, channelId string, offset int, limit int) (*model.PostList, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.PostStore.GetFlaggedPostsForChannel(userId, channelId, offset, limit)
|
||||
@@ -4414,7 +4414,7 @@ func (s *TimerLayerPostStore) GetFlaggedPostsForChannel(userId string, channelId
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerPostStore) GetFlaggedPostsForTeam(userId string, teamId string, offset int, limit int) (*model.PostList, *model.AppError) {
|
||||
func (s *TimerLayerPostStore) GetFlaggedPostsForTeam(userId string, teamId string, offset int, limit int) (*model.PostList, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.PostStore.GetFlaggedPostsForTeam(userId, teamId, offset, limit)
|
||||
@@ -4494,7 +4494,7 @@ func (s *TimerLayerPostStore) GetParentsForExportAfter(limit int, afterId string
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerPostStore) GetPostAfterTime(channelId string, time int64) (*model.Post, *model.AppError) {
|
||||
func (s *TimerLayerPostStore) GetPostAfterTime(channelId string, time int64) (*model.Post, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.PostStore.GetPostAfterTime(channelId, time)
|
||||
@@ -4510,7 +4510,7 @@ func (s *TimerLayerPostStore) GetPostAfterTime(channelId string, time int64) (*m
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerPostStore) GetPostIdAfterTime(channelId string, time int64) (string, *model.AppError) {
|
||||
func (s *TimerLayerPostStore) GetPostIdAfterTime(channelId string, time int64) (string, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.PostStore.GetPostIdAfterTime(channelId, time)
|
||||
@@ -4526,7 +4526,7 @@ func (s *TimerLayerPostStore) GetPostIdAfterTime(channelId string, time int64) (
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerPostStore) GetPostIdBeforeTime(channelId string, time int64) (string, *model.AppError) {
|
||||
func (s *TimerLayerPostStore) GetPostIdBeforeTime(channelId string, time int64) (string, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.PostStore.GetPostIdBeforeTime(channelId, time)
|
||||
@@ -4558,7 +4558,7 @@ func (s *TimerLayerPostStore) GetPosts(options model.GetPostsOptions, allowFromC
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerPostStore) GetPostsAfter(options model.GetPostsOptions) (*model.PostList, *model.AppError) {
|
||||
func (s *TimerLayerPostStore) GetPostsAfter(options model.GetPostsOptions) (*model.PostList, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.PostStore.GetPostsAfter(options)
|
||||
@@ -4590,7 +4590,7 @@ func (s *TimerLayerPostStore) GetPostsBatchForIndexing(startTime int64, endTime
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerPostStore) GetPostsBefore(options model.GetPostsOptions) (*model.PostList, *model.AppError) {
|
||||
func (s *TimerLayerPostStore) GetPostsBefore(options model.GetPostsOptions) (*model.PostList, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.PostStore.GetPostsBefore(options)
|
||||
@@ -4638,7 +4638,7 @@ func (s *TimerLayerPostStore) GetPostsCreatedAt(channelId string, time int64) ([
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerPostStore) GetPostsSince(options model.GetPostsSinceOptions, allowFromCache bool) (*model.PostList, *model.AppError) {
|
||||
func (s *TimerLayerPostStore) GetPostsSince(options model.GetPostsSinceOptions, allowFromCache bool) (*model.PostList, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.PostStore.GetPostsSince(options, allowFromCache)
|
||||
|
||||
Ссылка в новой задаче
Block a user