diff --git a/src/Share/Postgres/Queries.hs b/src/Share/Postgres/Queries.hs index 88c0055a..43fd9f89 100644 --- a/src/Share/Postgres/Queries.hs +++ b/src/Share/Postgres/Queries.hs @@ -707,59 +707,69 @@ listBranchesByProject :: BranchKindFilter -> ProjectId -> -- | (branch, contributorHandle) - PG.Transaction e [(Branch CausalId, Maybe UserHandle)] + PG.Transaction e (Paged (UTCTime, BranchId) (Branch CausalId, Maybe UserHandle)) listBranchesByProject limit mayCursor mayBranchNamePrefix mayContributorQuery kind projectId = do - let kindFilter = case kind of - AllBranchKinds -> "" - OnlyContributorBranches -> "AND b.contributor_id IS NOT NULL" - OnlyCoreBranches -> "AND b.contributor_id IS NULL" - let contributorFilter = case mayContributorQuery of - Nothing -> mempty - -- Allow null contributor here for the case where we're listing 'all' branch kinds. - Just (Left contributorId) -> [PG.sql| AND (b.contributor_id IS NULL OR (b.contributor_id = #{contributorId})) |] - Just (Right (Query contributorHandlePrefix)) -> [PG.sql| AND (contributor.handle IS NULL OR starts_with(contributor.handle, #{contributorHandlePrefix})) |] - let branchNameFilter = case mayBranchNamePrefix of - Nothing -> mempty - Just (Query branchNamePrefix) -> [PG.sql| AND starts_with(b.name, #{branchNamePrefix}) |] - let cursorFilter = case mayCursor of - Nothing -> mempty - Just (Cursor (beforeTime, branchId) Previous) -> [PG.sql| AND (b.updated_at, b.id) < (#{beforeTime}, #{branchId})|] - Just (Cursor (afterTime, branchId) Next) -> [PG.sql| AND (b.updated_at, b.id) > (#{afterTime}, #{branchId})|] - let sql = - intercalateMap - "\n" - id - [ ( [PG.sql| - SELECT - b.id, - b.project_id, - b.name, - b.contributor_id, - b.causal_id, - b.merge_target_branch_id, - b.created_at, - b.updated_at, - b.creator_id, - contributor.handle - FROM project_branches b - LEFT JOIN users AS contributor ON contributor.id = b.contributor_id - WHERE - b.deleted_at IS NULL - AND b.project_id = #{projectId} + results <- query limit (mkCursorFilter mayCursor) + let paged@(Paged {prevCursor, nextCursor}) = + results + & pagedOn (\(Branch {updatedAt, branchId}, _) -> (updatedAt, branchId)) + hasPrevPage <- not . null <$> query 1 (mkCursorFilter prevCursor) + hasNextPage <- not . null <$> query 1 (mkCursorFilter nextCursor) + pure $ guardPaged hasPrevPage hasNextPage paged + where + mkCursorFilter cursor = case cursor of + Nothing -> mempty + Just (Cursor (afterTime, branchId) Previous) -> [PG.sql| AND (b.updated_at, b.id) > (#{afterTime}, #{branchId})|] + Just (Cursor (beforeTime, branchId) Next) -> [PG.sql| AND (b.updated_at, b.id) < (#{beforeTime}, #{branchId})|] + kindFilter = case kind of + AllBranchKinds -> "" + OnlyContributorBranches -> "AND b.contributor_id IS NOT NULL" + OnlyCoreBranches -> "AND b.contributor_id IS NULL" + contributorFilter = case mayContributorQuery of + Nothing -> mempty + -- Allow null contributor here for the case where we're listing 'all' branch kinds. + Just (Left contributorId) -> [PG.sql| AND (b.contributor_id IS NULL OR (b.contributor_id = #{contributorId})) |] + Just (Right (Query contributorHandlePrefix)) -> [PG.sql| AND (contributor.handle IS NULL OR starts_with(contributor.handle, #{contributorHandlePrefix})) |] + branchNameFilter = case mayBranchNamePrefix of + Nothing -> mempty + Just (Query branchNamePrefix) -> [PG.sql| AND starts_with(b.name, #{branchNamePrefix}) |] + query :: Limit -> PG.Sql -> PG.Transaction e [(Branch CausalId, Maybe UserHandle)] + query limit cursorFilter = do + let sql = + intercalateMap + "\n" + id + [ ( [PG.sql| + SELECT + b.id, + b.project_id, + b.name, + b.contributor_id, + b.causal_id, + b.merge_target_branch_id, + b.created_at, + b.updated_at, + b.creator_id, + contributor.handle + FROM project_branches b + LEFT JOIN users AS contributor ON contributor.id = b.contributor_id + WHERE + b.deleted_at IS NULL + AND b.project_id = #{projectId} + |] + ), + kindFilter, + contributorFilter, + branchNameFilter, + cursorFilter, + ( [PG.sql| + ORDER BY b.updated_at DESC, b.id DESC + LIMIT #{limit} |] - ), - kindFilter, - contributorFilter, - branchNameFilter, - cursorFilter, - ( [PG.sql| - ORDER BY b.updated_at DESC, b.id DESC - LIMIT #{limit} - |] - ) - ] - PG.queryListRows sql - <&> fmap (\(branch PG.:. PG.Only contributorHandle) -> (branch, contributorHandle)) + ) + ] + PG.queryListRows sql + <&> fmap (\(branch PG.:. PG.Only contributorHandle) -> (branch, contributorHandle)) -- | List all BranchHashes which are reachable within a given user's codebase. accessibleCausalsForUser :: @@ -817,63 +827,72 @@ listContributorBranchesOfUserAccessibleToCaller :: Maybe (Cursor (UTCTime, BranchId)) -> Maybe Query -> Maybe ProjectId -> - -- | (branch, project, projectOwnerHandle) - PG.Transaction e [(Branch CausalId, Project, ProjectOwner)] + PG.Transaction e (Paged (UTCTime, BranchId) (Branch CausalId, Project, ProjectOwner)) listContributorBranchesOfUserAccessibleToCaller contributorUserId mayCallerUserId limit mayCursor mayBranchNamePrefix mayProjectId = do - let branchNameFilter = case mayBranchNamePrefix of - Nothing -> mempty - Just (Query branchNamePrefix) -> [PG.sql| AND starts_with(b.name, #{branchNamePrefix}) |] - let cursorFilter = case mayCursor of - Nothing -> mempty - Just (Cursor (beforeTime, branchId) Previous) -> [PG.sql| AND (b.updated_at, b.id) < (#{beforeTime}, #{branchId}) |] - Just (Cursor (afterTime, branchId) Next) -> [PG.sql| AND (b.updated_at, b.id) > (#{afterTime}, #{branchId}) |] - let projectFilter = case mayProjectId of - Nothing -> mempty - Just projId -> [PG.sql| AND b.project_id = #{projId} |] - let sql = - intercalateMap - "\n" - id - [ [PG.sql| - SELECT - b.id, - b.project_id, - b.name, - b.contributor_id, - b.causal_id, - b.merge_target_branch_id, - b.created_at, - b.updated_at, - b.creator_id, - project.id, - project.owner_user_id, - project.slug, - project.summary, - project.tags, - project.private, - project.created_at, - project.updated_at, - project_owner.handle, - project_owner.name, - EXISTS (SELECT FROM org_members WHERE org_members.organization_user_id = project.owner_user_id) - FROM project_branches b - JOIN projects project ON project.id = b.project_id - JOIN users AS project_owner ON project_owner.id = project.owner_user_id - WHERE - b.deleted_at IS NULL - AND b.contributor_id = #{contributorUserId} - AND user_has_project_permission(#{mayCallerUserId}, b.project_id, #{ProjectView}) - |], - branchNameFilter, - cursorFilter, - projectFilter, - [PG.sql| - ORDER BY b.updated_at DESC, b.id DESC - LIMIT #{limit} - |] - ] - PG.queryListRows sql - <&> fmap (\(branch PG.:. project PG.:. projectOwner) -> (branch, project, projectOwner)) + results <- query limit (mkCursorFilter mayCursor) + let paged@(Paged {prevCursor, nextCursor}) = + results + & pagedOn (\(Branch {updatedAt, branchId}, _, _) -> (updatedAt, branchId)) + hasPrevPage <- not . null <$> query 1 (mkCursorFilter prevCursor) + hasNextPage <- not . null <$> query 1 (mkCursorFilter nextCursor) + pure $ guardPaged hasPrevPage hasNextPage paged + where + branchNameFilter = case mayBranchNamePrefix of + Nothing -> mempty + Just (Query branchNamePrefix) -> [PG.sql| AND starts_with(b.name, #{branchNamePrefix}) |] + mkCursorFilter cursor = case cursor of + Nothing -> mempty + Just (Cursor (afterTime, branchId) Previous) -> [PG.sql| AND (b.updated_at, b.id) > (#{afterTime}, #{branchId}) |] + Just (Cursor (beforeTime, branchId) Next) -> [PG.sql| AND (b.updated_at, b.id) < (#{beforeTime}, #{branchId}) |] + projectFilter = case mayProjectId of + Nothing -> mempty + Just projId -> [PG.sql| AND b.project_id = #{projId} |] + query :: Limit -> PG.Sql -> PG.Transaction e [(Branch CausalId, Project, ProjectOwner)] + query limit cursorFilter = do + let sql = + intercalateMap + "\n" + id + [ [PG.sql| + SELECT + b.id, + b.project_id, + b.name, + b.contributor_id, + b.causal_id, + b.merge_target_branch_id, + b.created_at, + b.updated_at, + b.creator_id, + project.id, + project.owner_user_id, + project.slug, + project.summary, + project.tags, + project.private, + project.created_at, + project.updated_at, + project_owner.handle, + project_owner.name, + EXISTS (SELECT FROM org_members WHERE org_members.organization_user_id = project.owner_user_id) + FROM project_branches b + JOIN projects project ON project.id = b.project_id + JOIN users AS project_owner ON project_owner.id = project.owner_user_id + WHERE + b.deleted_at IS NULL + AND b.contributor_id = #{contributorUserId} + AND user_has_project_permission(#{mayCallerUserId}, b.project_id, #{ProjectView}) + |], + branchNameFilter, + cursorFilter, + projectFilter, + [PG.sql| + ORDER BY b.updated_at DESC, b.id DESC + LIMIT #{limit} + |] + ] + PG.queryListRows sql + <&> fmap (\(branch PG.:. project PG.:. projectOwner) -> (branch, project, projectOwner)) -- | Returns Project Owner information, including whether that user is an organization or not. projectOwnerByProjectId :: ProjectId -> PG.Transaction e (Maybe ProjectOwner) diff --git a/src/Share/Web/Share/Branches/Impl.hs b/src/Share/Web/Share/Branches/Impl.hs index 1bf9aa51..4496ac37 100644 --- a/src/Share/Web/Share/Branches/Impl.hs +++ b/src/Share/Web/Share/Branches/Impl.hs @@ -43,6 +43,8 @@ import Share.Web.Share.Branches.API qualified as API import Share.Web.Share.Branches.Types (BranchKindFilter (..), ShareBranch (..)) import Share.Web.Share.Branches.Types qualified as API import Share.Web.Share.CodeBrowsing.API qualified as API +import Share.Web.Share.Contributions.Types +import Share.Web.Share.DisplayInfo.Types import Share.Web.Share.Projects.Types (projectToAPI) import Share.Web.Share.Types import U.Codebase.HashTags (CausalHash) @@ -535,7 +537,7 @@ listBranchesByProjectEndpoint (AuthN.MaybeAuthedUserID callerUserId) userHandle (mayNamePrefix, mayContributorFilter) <- computeSearchFilters branches <- PG.runTransaction do branches <- Q.listBranchesByProject limit mayCursor mayNamePrefix mayContributorFilter (fromMaybe defaultKindFilter mayKindFilter) projectId - branchesWithContributions <- + branchesWithContributions :: (Paged (UTCTime, BranchId) (Branch CausalId, [ShareContribution UserDisplayInfo], Maybe UserHandle)) <- branches & fmap (\(branch@(Branch {branchId}), contributorHandle) -> (branch, branchId, contributorHandle)) & ContributionsQ.shareContributionsByBranchOf (traversed . _2) @@ -549,10 +551,7 @@ listBranchesByProjectEndpoint (AuthN.MaybeAuthedUserID callerUserId) userHandle let branchShortHand = BranchShortHand {branchName, contributorHandle} in API.branchToShareBranch branchShortHand branch shareProject contributions ) - branches - & pagedOn (\(Branch {updatedAt, branchId}, _, _) -> (updatedAt, branchId)) - & (\p -> p {items = shareBranches}) - & pure + pure shareBranches where userIdForHandle handle = do fmap user_id <$> PG.runTransaction (UserQ.userByHandle handle) @@ -628,10 +627,7 @@ listBranchesByUserEndpoint (AuthN.MaybeAuthedUserID callerUserId) contributorHan shareProject = projectToAPI projectOwnerHandle project in API.branchToShareBranch branchShortHand branch shareProject contributions ) - expandedBranches - & pagedOn ((\(Branch {updatedAt, branchId}, _contr, _proj, _projOwner) -> (updatedAt, branchId))) - & (\p -> p {items = shareBranches}) - & pure + pure shareBranches where defaultLimit = Limit 20 limit = fromMaybe defaultLimit mayLimit diff --git a/transcripts/share-apis/branches/branch-list-by-self-name-prefix.json b/transcripts/share-apis/branches/branch-list-by-self-name-prefix.json index 71aba781..3b4b0019 100644 --- a/transcripts/share-apis/branches/branch-list-by-self-name-prefix.json +++ b/transcripts/share-apis/branches/branch-list-by-self-name-prefix.json @@ -61,8 +61,8 @@ "updatedAt": "" } ], - "nextCursor": "", - "prevCursor": "" + "nextCursor": null, + "prevCursor": null }, "status": [ { diff --git a/transcripts/share-apis/branches/branch-list-by-self-project-ref.json b/transcripts/share-apis/branches/branch-list-by-self-project-ref.json index 71aba781..3b4b0019 100644 --- a/transcripts/share-apis/branches/branch-list-by-self-project-ref.json +++ b/transcripts/share-apis/branches/branch-list-by-self-project-ref.json @@ -61,8 +61,8 @@ "updatedAt": "" } ], - "nextCursor": "", - "prevCursor": "" + "nextCursor": null, + "prevCursor": null }, "status": [ { diff --git a/transcripts/share-apis/branches/branch-list-by-user-self.json b/transcripts/share-apis/branches/branch-list-by-user-self.json index e65072f1..687737b8 100644 --- a/transcripts/share-apis/branches/branch-list-by-user-self.json +++ b/transcripts/share-apis/branches/branch-list-by-user-self.json @@ -81,8 +81,8 @@ "updatedAt": "" } ], - "nextCursor": "", - "prevCursor": "" + "nextCursor": null, + "prevCursor": null }, "status": [ { diff --git a/transcripts/share-apis/branches/branch-list-contributor-filter.json b/transcripts/share-apis/branches/branch-list-contributor-filter.json index 2584de7a..c54caa62 100644 --- a/transcripts/share-apis/branches/branch-list-contributor-filter.json +++ b/transcripts/share-apis/branches/branch-list-contributor-filter.json @@ -101,8 +101,8 @@ "updatedAt": "" } ], - "nextCursor": "", - "prevCursor": "" + "nextCursor": null, + "prevCursor": null }, "status": [ { diff --git a/transcripts/share-apis/branches/branch-list-contributor-prefix.json b/transcripts/share-apis/branches/branch-list-contributor-prefix.json index 2584de7a..c54caa62 100644 --- a/transcripts/share-apis/branches/branch-list-contributor-prefix.json +++ b/transcripts/share-apis/branches/branch-list-contributor-prefix.json @@ -101,8 +101,8 @@ "updatedAt": "" } ], - "nextCursor": "", - "prevCursor": "" + "nextCursor": null, + "prevCursor": null }, "status": [ { diff --git a/transcripts/share-apis/branches/branch-list-contributors-only.json b/transcripts/share-apis/branches/branch-list-contributors-only.json index 71aba781..3b4b0019 100644 --- a/transcripts/share-apis/branches/branch-list-contributors-only.json +++ b/transcripts/share-apis/branches/branch-list-contributors-only.json @@ -61,8 +61,8 @@ "updatedAt": "" } ], - "nextCursor": "", - "prevCursor": "" + "nextCursor": null, + "prevCursor": null }, "status": [ { diff --git a/transcripts/share-apis/branches/branch-list-core-only.json b/transcripts/share-apis/branches/branch-list-core-only.json index 4f5a5454..c20639f2 100644 --- a/transcripts/share-apis/branches/branch-list-core-only.json +++ b/transcripts/share-apis/branches/branch-list-core-only.json @@ -42,8 +42,8 @@ "updatedAt": "" } ], - "nextCursor": "", - "prevCursor": "" + "nextCursor": null, + "prevCursor": null }, "status": [ { diff --git a/transcripts/share-apis/branches/branch-list-name-filter.json b/transcripts/share-apis/branches/branch-list-name-filter.json index 935a00e8..b030e5f5 100644 --- a/transcripts/share-apis/branches/branch-list-name-filter.json +++ b/transcripts/share-apis/branches/branch-list-name-filter.json @@ -22,8 +22,8 @@ "updatedAt": "" } ], - "nextCursor": "", - "prevCursor": "" + "nextCursor": null, + "prevCursor": null }, "status": [ { diff --git a/transcripts/share-apis/branches/branch-list-name-prefix.json b/transcripts/share-apis/branches/branch-list-name-prefix.json index 71aba781..3b4b0019 100644 --- a/transcripts/share-apis/branches/branch-list-name-prefix.json +++ b/transcripts/share-apis/branches/branch-list-name-prefix.json @@ -61,8 +61,8 @@ "updatedAt": "" } ], - "nextCursor": "", - "prevCursor": "" + "nextCursor": null, + "prevCursor": null }, "status": [ { diff --git a/transcripts/share-apis/branches/branch-list-page-1.json b/transcripts/share-apis/branches/branch-list-page-1.json new file mode 100644 index 00000000..abfb136a --- /dev/null +++ b/transcripts/share-apis/branches/branch-list-page-1.json @@ -0,0 +1,72 @@ +{ + "body": { + "items": [ + { + "branchRef": "@transcripts/contribution", + "causalHash": "#sg60bvjo91fsoo7pkh9gejbn0qgc95vra87ap6l5d35ri0lkaudl7bs12d71sf3fh6p23teemuor7mk1i9n567m50ibakcghjec5ajg", + "contributions": [ + { + "author": { + "avatarUrl": null, + "handle": "test", + "name": null, + "userId": "U-" + }, + "createdAt": "", + "description": "Adds pagination functionality to the user list page in the admin panel to improve performance and user experience.\n## Changes Made:\n\n* Implemented pagination using the Paginator type.\n* Updated the user list view to display a paginated list.\n* Added a new route for paginated user list.\n\n## Testing:\n\nI tested the pagination feature with a large dataset to ensure it functions correctly. I also tested edge cases and confirmed that the user list is now paginated as expected.\n", + "id": "C-", + "numComments": 0, + "number": 2, + "projectRef": "@test/publictestproject", + "sourceBranchRef": "@transcripts/contribution", + "status": "in_review", + "targetBranchRef": "main", + "title": "Add pagination to user list", + "updatedAt": "" + }, + { + "author": { + "avatarUrl": null, + "handle": "test", + "name": null, + "userId": "U-" + }, + "createdAt": "", + "description": "This contribution addresses an issue where users were unable to log in due to a validation error in the authentication process.\n\n## Changes made:\n\n* Modified the validation logic for the Auth type to properly authenticate users.\n* Added unit tests to ensure the authentication process works as expected.\n\n## Testing:\n\nI tested this change locally on my development environment and confirmed that users can now log in without any issues. All unit tests are passing.", + "id": "C-", + "numComments": 2, + "number": 1, + "projectRef": "@test/publictestproject", + "sourceBranchRef": "@transcripts/contribution", + "status": "in_review", + "targetBranchRef": "main", + "title": "Fix issue with user authentication", + "updatedAt": "" + } + ], + "createdAt": "", + "project": { + "createdAt": "", + "owner": { + "handle": "@test", + "name": null, + "type": "user" + }, + "slug": "publictestproject", + "summary": "test project summary", + "tags": [], + "updatedAt": "", + "visibility": "public" + }, + "updatedAt": "" + } + ], + "nextCursor": "", + "prevCursor": null + }, + "status": [ + { + "status_code": 200 + } + ] +} diff --git a/transcripts/share-apis/branches/branch-list-page-2.json b/transcripts/share-apis/branches/branch-list-page-2.json new file mode 100644 index 00000000..5604021d --- /dev/null +++ b/transcripts/share-apis/branches/branch-list-page-2.json @@ -0,0 +1,33 @@ +{ + "body": { + "items": [ + { + "branchRef": "feature", + "causalHash": "#sg60bvjo91fsoo7pkh9gejbn0qgc95vra87ap6l5d35ri0lkaudl7bs12d71sf3fh6p23teemuor7mk1i9n567m50ibakcghjec5ajg", + "contributions": [], + "createdAt": "", + "project": { + "createdAt": "", + "owner": { + "handle": "@test", + "name": null, + "type": "user" + }, + "slug": "publictestproject", + "summary": "test project summary", + "tags": [], + "updatedAt": "", + "visibility": "public" + }, + "updatedAt": "" + } + ], + "nextCursor": "", + "prevCursor": "" + }, + "status": [ + { + "status_code": 200 + } + ] +} diff --git a/transcripts/share-apis/branches/branch-list-prev-page.json b/transcripts/share-apis/branches/branch-list-prev-page.json new file mode 100644 index 00000000..abfb136a --- /dev/null +++ b/transcripts/share-apis/branches/branch-list-prev-page.json @@ -0,0 +1,72 @@ +{ + "body": { + "items": [ + { + "branchRef": "@transcripts/contribution", + "causalHash": "#sg60bvjo91fsoo7pkh9gejbn0qgc95vra87ap6l5d35ri0lkaudl7bs12d71sf3fh6p23teemuor7mk1i9n567m50ibakcghjec5ajg", + "contributions": [ + { + "author": { + "avatarUrl": null, + "handle": "test", + "name": null, + "userId": "U-" + }, + "createdAt": "", + "description": "Adds pagination functionality to the user list page in the admin panel to improve performance and user experience.\n## Changes Made:\n\n* Implemented pagination using the Paginator type.\n* Updated the user list view to display a paginated list.\n* Added a new route for paginated user list.\n\n## Testing:\n\nI tested the pagination feature with a large dataset to ensure it functions correctly. I also tested edge cases and confirmed that the user list is now paginated as expected.\n", + "id": "C-", + "numComments": 0, + "number": 2, + "projectRef": "@test/publictestproject", + "sourceBranchRef": "@transcripts/contribution", + "status": "in_review", + "targetBranchRef": "main", + "title": "Add pagination to user list", + "updatedAt": "" + }, + { + "author": { + "avatarUrl": null, + "handle": "test", + "name": null, + "userId": "U-" + }, + "createdAt": "", + "description": "This contribution addresses an issue where users were unable to log in due to a validation error in the authentication process.\n\n## Changes made:\n\n* Modified the validation logic for the Auth type to properly authenticate users.\n* Added unit tests to ensure the authentication process works as expected.\n\n## Testing:\n\nI tested this change locally on my development environment and confirmed that users can now log in without any issues. All unit tests are passing.", + "id": "C-", + "numComments": 2, + "number": 1, + "projectRef": "@test/publictestproject", + "sourceBranchRef": "@transcripts/contribution", + "status": "in_review", + "targetBranchRef": "main", + "title": "Fix issue with user authentication", + "updatedAt": "" + } + ], + "createdAt": "", + "project": { + "createdAt": "", + "owner": { + "handle": "@test", + "name": null, + "type": "user" + }, + "slug": "publictestproject", + "summary": "test project summary", + "tags": [], + "updatedAt": "", + "visibility": "public" + }, + "updatedAt": "" + } + ], + "nextCursor": "", + "prevCursor": null + }, + "status": [ + { + "status_code": 200 + } + ] +} diff --git a/transcripts/share-apis/branches/branch-list-private.json b/transcripts/share-apis/branches/branch-list-private.json index e65072f1..687737b8 100644 --- a/transcripts/share-apis/branches/branch-list-private.json +++ b/transcripts/share-apis/branches/branch-list-private.json @@ -81,8 +81,8 @@ "updatedAt": "" } ], - "nextCursor": "", - "prevCursor": "" + "nextCursor": null, + "prevCursor": null }, "status": [ { diff --git a/transcripts/share-apis/branches/branch-list.json b/transcripts/share-apis/branches/branch-list.json index 2584de7a..c54caa62 100644 --- a/transcripts/share-apis/branches/branch-list.json +++ b/transcripts/share-apis/branches/branch-list.json @@ -101,8 +101,8 @@ "updatedAt": "" } ], - "nextCursor": "", - "prevCursor": "" + "nextCursor": null, + "prevCursor": null }, "status": [ { diff --git a/transcripts/share-apis/branches/run.zsh b/transcripts/share-apis/branches/run.zsh index 92869b39..05d8874e 100755 --- a/transcripts/share-apis/branches/run.zsh +++ b/transcripts/share-apis/branches/run.zsh @@ -42,8 +42,16 @@ fetch "$transcripts_user" GET branch-list-private '/users/transcripts/branches' # Branch details fetch "$transcripts_user" GET branch-details '/users/test/projects/publictestproject/branches/main' +# Paging tests +fetch "$transcripts_user" GET branch-list-page-1 '/users/test/projects/publictestproject/branches?limit=1' +next_cursor=$(fetch_data_jq "$transcripts_user" GET branch-list-paged '/users/test/projects/publictestproject/branches?limit=1' '.nextCursor') +fetch "$transcripts_user" GET branch-list-page-2 "/users/test/projects/publictestproject/branches?limit=1&cursor=$next_cursor" +prev_cursor=$(fetch_data_jq "$transcripts_user" GET branch-list-page-2 "/users/test/projects/publictestproject/branches?limit=1&cursor=$next_cursor" '.prevCursor') +fetch "$transcripts_user" GET branch-list-prev-page "/users/test/projects/publictestproject/branches?limit=1&cursor=$prev_cursor" + # Delete a branch fetch "$test_user" DELETE branch-delete '/users/test/projects/publictestproject/branches/main' # Branch should no longer exist fetch "$test_user" GET branch-details-deleted '/users/test/projects/publictestproject/branches/main' +