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

feat: Implement Pagination for GET /progreses API #2325

Conversation

AnujChhikara
Copy link
Member

@AnujChhikara AnujChhikara commented Dec 29, 2024

Date: 29 Dec 2024

Developer Name: @AnujChhikara


Issue Ticket Number

Description

This PR introduces pagination support for the GET /progreses API, aimed at improving the performance and scalability when dealing with large datasets. The feature is currently gated behind a development flag for testing. By default, the size is set to 100 items per page.
Additionally, the API response includes links for easy navigation between pages (prev and next links).

Pagination Parameters:

Introduced support for page and size query parameters in the GET /progreses API.
page: The page number to retrieve (defaults to 0 if not specified).
size: The number of items per page. The size can be a value between 1 and 100. If not specified, it defaults to 100.

Pagination Links:

Included prev and next links in the response to allow easy navigation between pages:
prev: URL to the previous page (if applicable).
next: URL to the next page (if applicable).

Changes

Documentation Updated?

  • Yes
  • No

Under Feature Flag

  • Yes
  • No

Database Changes

  • Yes
  • No

Breaking Changes

  • Yes
  • No

Development Tested?

  • Yes
  • No

Screenshots

Screenshot 1
pagination.mp4

Test Coverage

Screenshot 1

image
image

Additional Notes

{
    "message": "Progress document retrieved successfully.",
    "count": 1,
    "data": [
        {
            "id": "m7Z9MhIKD3uHZRzNgTpq",
            "type": "task",
            "taskId": "ytxKmLKh0To7bPfGJ4Fk",
            "completed": "Working on a backend Go project",
            "planned": "Implement error handling for API endpoints",
            "blockers": "Waiting for database access credentials",
            "userId": "bbbDuABnkSL4b5FFVite",
            "createdAt": 1735468639619,
            "date": 1735430400000
        }
    ],
    "links": {
        "prev": "/progresses?type=task&page=0&size=1&dev=true",
        "next": "/progresses?type=task&page=2&size=1&dev=true"
    }
}
  • I opted to create separate functions for pagination instead of modifying the existing one. This approach makes it easier to remove the 'dev' flag later on.

controllers/progresses.js Outdated Show resolved Hide resolved
models/progresses.js Outdated Show resolved Hide resolved
@Achintya-Chatterjee Achintya-Chatterjee changed the title Implement Pagination for GET /progreses API feat: Implement Pagination for GET /progreses API Jan 1, 2025
models/progresses.js Outdated Show resolved Hide resolved
utils/progresses.js Outdated Show resolved Hide resolved
controllers/progresses.js Outdated Show resolved Hide resolved
models/progresses.js Outdated Show resolved Hide resolved
utils/progresses.js Outdated Show resolved Hide resolved
@vinit717
Copy link
Member

video is not working and can you please add more progreses

@AnujChhikara
Copy link
Member Author

video is not working and can you please add more progreses

Hello @vinit717 video is working for me but i have also added a second video when free please check

@vinit717
Copy link
Member

can you add test coverage screenshot not test passing

@AnujChhikara
Copy link
Member Author

can you add test coverage screenshot not test passing

Hello @vinit717 this is the test PR for this code changes Test PR

@iamitprakash iamitprakash merged commit cbd992a into Real-Dev-Squad:develop Jan 22, 2025
3 checks passed
@AnujChhikara AnujChhikara deleted the feature/pagination-get-progresses-api branch January 22, 2025 12:18
@pankajjs pankajjs mentioned this pull request Jan 23, 2025
10 tasks
iamitprakash added a commit that referenced this pull request Jan 26, 2025
* chore: remove duplicate function call for onboarding extension request (#2361)

* feat: Implement Pagination for GET /progreses API (#2325)

* feat: add pagination to GET /progreses API

* fix returning 404 on a page with no data

* fix joi validator logic

* refactor getting totalcount logic

* fix dev true

* fix merge conflicts

* using constant

* maked the JsDoc more concise

---------

Co-authored-by: Vinit khandal <111434418+vinit717@users.noreply.github.com>

* test : add tests for pagination of progresses api (#2328)

* added test for the get progresses pagination

* added test for dev=false

* minor fix

* added unit test for utils/progresses functions

* added progressed model unit tests

* added test for 500

* added 500 message from constant

* fix test naming

* feat: Add an API to edit onboarding extension request details before approval or rejection (#2334)

* feat: Add feature to update request before approval or rejection
- Add common validator to redirect request based on type of extension
- Add type field in onboarding extension validator
- Import addLog from services to make it available for stubbing while testing
- Moved response messages to constants file
- Reuse single instance of current date in request and log model for consistent data

- Change controller name

- Remove unused variables

- Add authorization check for superuser or request ownership

- Change authorization condition

- Remove unnecessary changes

* fix: add logs for failure cases and fix check for same old and new deadline

* refactor: separate validation and update logic in service file

* chore: fix jsDoc

* fix: send id instead of while request doc while updating it

* chore: fix lint issue

* fix: change validation response condition and fix jsDoc

* fix: add strict checking

* fix: change constant message

* feat: Add tests for PATCH /requests/:id API for onboarding extension requests (#2335)

* feat: Add test cases for controller and validator

- Remove failing tests and fix existing tests

- Add tests to check success and unexpected behaviour and fix existing tests

- Replace actual messages with constants for easily maintenance

- Add test for super user and request owner authorization check and fix existing failing tests

- Remove un-necessary changes

- Remove separate file for validator tests

* feat: add tests for onboarding update and validate service

* Merge pull request #2369 from pankajjs/fix/flaky-test

Fix flaky test present in PR[2335]

* fix: handle id query parameter in Get Requests API (#2367)

Co-authored-by: Vikas Singh <59792866+vikasosmium@users.noreply.github.com>
Co-authored-by: Achintya Chatterjee <55826451+Achintya-Chatterjee@users.noreply.github.com>

---------

Co-authored-by: Yash Raj <56453897+yesyash@users.noreply.github.com>
Co-authored-by: Pankaj <pankajshadev@gmail.com>
Co-authored-by: Anuj Chhikara <107175639+AnujChhikara@users.noreply.github.com>
Co-authored-by: Vinit khandal <111434418+vinit717@users.noreply.github.com>
Co-authored-by: Vikas Singh <59792866+vikasosmium@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement Pagination with Limit for getProgressDocument
6 participants