Skip to content

Commit

Permalink
Export paginate method
Browse files Browse the repository at this point in the history
  • Loading branch information
jarrel-b committed Jun 19, 2024
1 parent b48e258 commit 4016416
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 21 deletions.
6 changes: 3 additions & 3 deletions publicapi/community.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func (api CommunityAPI) PaginateHoldersByCommunityID(ctx context.Context, commun
CountFunc: countFunc,
}

return paginator.paginate(before, after, first, last)
return paginator.Paginate(before, after, first, last)
}

func (api CommunityAPI) PaginatePostsByCommunityID(ctx context.Context, communityID persist.DBID, before, after *string, first, last *int) ([]db.Post, PageInfo, error) {
Expand Down Expand Up @@ -160,7 +160,7 @@ func (api CommunityAPI) PaginatePostsByCommunityID(ctx context.Context, communit
CountFunc: countFunc,
}

return paginator.paginate(before, after, first, last)
return paginator.Paginate(before, after, first, last)
}

func (api CommunityAPI) PaginateTokensByCommunityID(ctx context.Context, communityID persist.DBID, before, after *string, first, last *int) ([]db.Token, PageInfo, error) {
Expand Down Expand Up @@ -203,7 +203,7 @@ func (api CommunityAPI) PaginateTokensByCommunityID(ctx context.Context, communi
CountFunc: countFunc,
}

return paginator.paginate(before, after, first, last)
return paginator.Paginate(before, after, first, last)
}

// GetFrameTokensByCommunityID is temporary and shouldn't be used outside of the TokensForFrame resolver
Expand Down
6 changes: 3 additions & 3 deletions publicapi/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (api ContractAPI) GetChildContractsByParentID(ctx context.Context, contract
CursorFunc: cursorFunc,
}

return paginator.paginate(before, after, first, last)
return paginator.Paginate(before, after, first, last)
}

func (api ContractAPI) GetContractCreatorByContractID(ctx context.Context, contractID persist.DBID) (db.ContractCreator, error) {
Expand Down Expand Up @@ -245,7 +245,7 @@ func (api ContractAPI) GetCommunityPostsByContractID(ctx context.Context, contra
CountFunc: countFunc,
}

return paginator.paginate(before, after, first, last)
return paginator.Paginate(before, after, first, last)
}

// ------ Temporary ------
Expand Down Expand Up @@ -290,7 +290,7 @@ func (api ContractAPI) GetCommunityPostsByContractIDAndProjectID(ctx context.Con
CountFunc: countFunc,
}

return paginator.paginate(before, after, first, last)
return paginator.Paginate(before, after, first, last)
}

// End of temporary to-be-removed stuff
Expand Down
6 changes: 3 additions & 3 deletions publicapi/feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ func (api FeedAPI) PersonalFeed(ctx context.Context, before *string, after *stri
CursorFunc: feedCursor,
}

return paginator.paginate(before, after, first, last)
return paginator.Paginate(before, after, first, last)
}

func (api FeedAPI) UserFeed(ctx context.Context, userID persist.DBID, before *string, after *string, first *int, last *int) ([]db.Post, PageInfo, error) {
Expand Down Expand Up @@ -483,7 +483,7 @@ func (api FeedAPI) UserFeed(ctx context.Context, userID persist.DBID, before *st
CountFunc: countFunc,
}

return paginator.paginate(before, after, first, last)
return paginator.Paginate(before, after, first, last)
}

func (api FeedAPI) GlobalFeed(ctx context.Context, before *string, after *string, first *int, last *int) ([]any, PageInfo, error) {
Expand Down Expand Up @@ -516,7 +516,7 @@ func (api FeedAPI) GlobalFeed(ctx context.Context, before *string, after *string
CursorFunc: feedCursor,
}

return paginator.paginate(before, after, first, last)
return paginator.Paginate(before, after, first, last)
}

func fetchFeedEntityScores(ctx context.Context, q *db.Queries, viewerID persist.DBID) ([]db.GetFeedEntityScoresRow, error) {
Expand Down
14 changes: 7 additions & 7 deletions publicapi/interaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ func (api InteractionAPI) PaginateAdmiresByFeedEventID(ctx context.Context, feed
CountFunc: countFunc,
}

return paginator.paginate(before, after, first, last)
return paginator.Paginate(before, after, first, last)
}

func (api InteractionAPI) PaginateAdmiresByCommentID(ctx context.Context, commentID persist.DBID, before *string, after *string, first *int, last *int) ([]db.Admire, PageInfo, error) {
Expand Down Expand Up @@ -355,7 +355,7 @@ func (api InteractionAPI) PaginateAdmiresByCommentID(ctx context.Context, commen
CountFunc: countFunc,
}

return paginator.paginate(before, after, first, last)
return paginator.Paginate(before, after, first, last)
}

func (api InteractionAPI) PaginateCommentsByFeedEventID(ctx context.Context, feedEventID persist.DBID, before *string, after *string, first *int, last *int) ([]db.Comment, PageInfo, error) {
Expand Down Expand Up @@ -397,7 +397,7 @@ func (api InteractionAPI) PaginateCommentsByFeedEventID(ctx context.Context, fee
CountFunc: countFunc,
}

return paginator.paginate(before, after, first, last)
return paginator.Paginate(before, after, first, last)
}

func (api InteractionAPI) PaginateRepliesByCommentID(ctx context.Context, commentID persist.DBID, before *string, after *string, first *int, last *int) ([]db.Comment, PageInfo, error) {
Expand Down Expand Up @@ -439,7 +439,7 @@ func (api InteractionAPI) PaginateRepliesByCommentID(ctx context.Context, commen
CountFunc: countFunc,
}

return paginator.paginate(before, after, first, last)
return paginator.Paginate(before, after, first, last)
}

func (api InteractionAPI) GetTotalCommentsByPostID(ctx context.Context, postID persist.DBID) (*int, error) {
Expand Down Expand Up @@ -514,7 +514,7 @@ func (api InteractionAPI) PaginateAdmiresByPostID(ctx context.Context, postID pe
CountFunc: countFunc,
}

return paginator.paginate(before, after, first, last)
return paginator.Paginate(before, after, first, last)
}

func (api InteractionAPI) PaginateAdmiresByTokenID(ctx context.Context, tokenID persist.DBID, before *string, after *string,
Expand Down Expand Up @@ -567,7 +567,7 @@ func (api InteractionAPI) PaginateAdmiresByTokenID(ctx context.Context, tokenID
CountFunc: countFunc,
}

return paginator.paginate(before, after, first, last)
return paginator.Paginate(before, after, first, last)
}

func (api InteractionAPI) PaginateCommentsByPostID(ctx context.Context, postID persist.DBID, before *string, after *string, first *int, last *int) ([]db.Comment, PageInfo, error) {
Expand Down Expand Up @@ -609,7 +609,7 @@ func (api InteractionAPI) PaginateCommentsByPostID(ctx context.Context, postID p
CountFunc: countFunc,
}

return paginator.paginate(before, after, first, last)
return paginator.Paginate(before, after, first, last)
}

func (api InteractionAPI) GetAdmireByActorIDAndFeedEventID(ctx context.Context, actorID persist.DBID, feedEventID persist.DBID) (*db.Admire, error) {
Expand Down
2 changes: 1 addition & 1 deletion publicapi/notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (api NotificationsAPI) GetViewerNotifications(ctx context.Context, before,
CountFunc: countFunc,
}

notifications, pageInfo, err := paginator.paginate(before, after, first, last)
notifications, pageInfo, err := paginator.Paginate(before, after, first, last)
if err != nil {
return nil, PageInfo{}, 0, err
}
Expand Down
2 changes: 1 addition & 1 deletion publicapi/pagination.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func withDefaultCursorTime(before, after time.Time) func(beforeCur, afterCur *ti
}
}

func (p *TimeIDPaginator[Node]) paginate(before *string, after *string, first *int, last *int, opts ...func(beforeCur, afterCur *timeIDCursor)) ([]Node, PageInfo, error) {
func (p *TimeIDPaginator[Node]) Paginate(before *string, after *string, first *int, last *int, opts ...func(beforeCur, afterCur *timeIDCursor)) ([]Node, PageInfo, error) {
queryFunc := func(limit int32, pagingForward bool) ([]Node, error) {
beforeCur := cursors.NewTimeIDCursor()
beforeCur.Time = defaultCursorBeforeTime
Expand Down
2 changes: 1 addition & 1 deletion publicapi/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func (api TokenAPI) GetTokensBookmarkedByUserId(ctx context.Context, userID pers
}

// swap the default cursor times because admires are returned in reverse chronological order
results, pageInfo, err := paginator.paginate(before, after, first, last, withDefaultCursorTime(defaultCursorAfterTime, defaultCursorBeforeTime))
results, pageInfo, err := paginator.Paginate(before, after, first, last, withDefaultCursorTime(defaultCursorAfterTime, defaultCursorBeforeTime))
tokens := util.MapWithoutError(results, func(r db.PaginateTokensAdmiredByUserIDBatchRow) db.Token { return r.Token })
return tokens, pageInfo, err
}
Expand Down
4 changes: 2 additions & 2 deletions publicapi/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func (api UserAPI) GetUsersByIDs(ctx context.Context, userIDs []persist.DBID, be
CountFunc: countFunc,
}

return paginator.paginate(before, after, first, last)
return paginator.Paginate(before, after, first, last)
}

func (api UserAPI) paginatorFromCursorStr(ctx context.Context, curStr string) (positionPaginator[db.User], error) {
Expand Down Expand Up @@ -1056,7 +1056,7 @@ func (api UserAPI) CreatedCommunities(ctx context.Context, userID persist.DBID,
CursorFunc: cursorFunc,
}

return paginator.paginate(before, after, first, last)
return paginator.Paginate(before, after, first, last)
}

func (api UserAPI) FollowUser(ctx context.Context, userID persist.DBID) error {
Expand Down

0 comments on commit 4016416

Please sign in to comment.