From 4016416358a221d1dbb35e50900273eabb989cc1 Mon Sep 17 00:00:00 2001 From: jarrel Date: Wed, 19 Jun 2024 13:47:12 -0700 Subject: [PATCH] Export paginate method --- publicapi/community.go | 6 +++--- publicapi/contract.go | 6 +++--- publicapi/feed.go | 6 +++--- publicapi/interaction.go | 14 +++++++------- publicapi/notifications.go | 2 +- publicapi/pagination.go | 2 +- publicapi/token.go | 2 +- publicapi/user.go | 4 ++-- 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/publicapi/community.go b/publicapi/community.go index 8e2cd28c3..cb8636558 100644 --- a/publicapi/community.go +++ b/publicapi/community.go @@ -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) { @@ -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) { @@ -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 diff --git a/publicapi/contract.go b/publicapi/contract.go index 684e3a379..456c6cb19 100644 --- a/publicapi/contract.go +++ b/publicapi/contract.go @@ -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) { @@ -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 ------ @@ -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 diff --git a/publicapi/feed.go b/publicapi/feed.go index 4d7593c02..56854925e 100644 --- a/publicapi/feed.go +++ b/publicapi/feed.go @@ -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) { @@ -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) { @@ -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) { diff --git a/publicapi/interaction.go b/publicapi/interaction.go index 3ef7be701..d907084d3 100644 --- a/publicapi/interaction.go +++ b/publicapi/interaction.go @@ -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) { @@ -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) { @@ -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) { @@ -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) { @@ -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, @@ -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) { @@ -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) { diff --git a/publicapi/notifications.go b/publicapi/notifications.go index 032b202fb..414ef51dc 100644 --- a/publicapi/notifications.go +++ b/publicapi/notifications.go @@ -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 } diff --git a/publicapi/pagination.go b/publicapi/pagination.go index b6a9dc7a9..3eb1c39bf 100644 --- a/publicapi/pagination.go +++ b/publicapi/pagination.go @@ -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 diff --git a/publicapi/token.go b/publicapi/token.go index 8376644c8..f56072f1c 100644 --- a/publicapi/token.go +++ b/publicapi/token.go @@ -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 } diff --git a/publicapi/user.go b/publicapi/user.go index 199ef77ad..9e1bafac3 100644 --- a/publicapi/user.go +++ b/publicapi/user.go @@ -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) { @@ -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 {