Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API: Add pagination metadata #336

Closed
rajdip-b opened this issue Jul 10, 2024 · 4 comments · Fixed by #394
Closed

API: Add pagination metadata #336

rajdip-b opened this issue Jul 10, 2024 · 4 comments · Fixed by #394
Assignees
Labels
difficulty: 4 foss hack Clustering all the curated issues for Foss Hack 2024 good first issue Good for newcomers help wanted Extra attention is needed priority: high scope: api Everything related to the API type: enhancement New feature or request

Comments

@rajdip-b
Copy link
Member

rajdip-b commented Jul 10, 2024

Description

Add the following fields when returning paginated response in every module:

  • page: The current page number
  • perPage: The number of items per page
  • pageCount: The total page count
  • totalCount: The total number of items present
  • links (All links to have the relative path. For example: /api/environment/all/:projectId?<query>)
    • self: The link to this current page
    • first: The link to the first page
    • previous: The link to the previous page
    • next: The link to the next page
    • last : The link to the last page

We want the computation to be done in the service classes.

Solution

  • Create a utility function under common module and name it paginate. This function should take in the page details and generate the pagination metadata
  • Update all the functions in the service layer that return paginated data to return the data in items and the metadata in metadata
  • Update the E2E test of the module to reflect on the changes

Objectives

This issue is the parent issue. Below you will find a list of issues that relate to this. These issues encompass the scope of change in every module:

@muntaxir4
Copy link
Contributor

muntaxir4 commented Jul 13, 2024

This will cause the return type of affected methods to be Objects such that to hold those required fields right? And currently these methods return Arrays of Objects. The new result would be like { items : [...], metadata:{...}}

@rajdip-b
Copy link
Member Author

Exactly!

@muntaxir4
Copy link
Contributor

Can you assign me the whole list of issues? As of now I have implemented locally for the Project module.

@rajdip-b
Copy link
Member Author

Hey @muntaxir4! Yeah, I think I can do that. Just note that, you would need to make the commits and put up the PR in the hackathon window :)

@rajdip-b rajdip-b moved this from Todo to In progress in keyshade-api Jul 14, 2024
@github-project-automation github-project-automation bot moved this from In progress to Done in keyshade-api Jul 29, 2024
@rajdip-b rajdip-b moved this from Done to Queued for release in keyshade-api Jul 29, 2024
@rajdip-b rajdip-b moved this from Queued for release to In progress in keyshade-api Jul 29, 2024
@rajdip-b rajdip-b moved this from In progress to Done in keyshade-api Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: 4 foss hack Clustering all the curated issues for Foss Hack 2024 good first issue Good for newcomers help wanted Extra attention is needed priority: high scope: api Everything related to the API type: enhancement New feature or request
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants