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 on find all team members #1276

Conversation

akinwalexander
Copy link

@akinwalexander akinwalexander commented Feb 28, 2025

Fixes #1229

Pull Request

Description

The findAllTeamMembers endpoint currently retrieves all team members from the database without any pagination. This could lead to performance issues and increased database load if there are a large number of team members. Implementing pagination will enhance efficiency and scalability.

Acceptance Criteria

  • The findAllTeamMembers endpoint should accept optional page and limit query parameters.
  • The TeamMemberService.findAllTeamMembers method should use page and limit parameters to implement pagination using skip and take (or equivalent ORM methods).
  • The API should return a paginated response with a subset of team members based on the page and limit parameters.
  • API documentation (Swagger) should be updated to reflect the new page and limit parameters for the findAllTeamMembers endpoint.
  • Default values for page and limit should be defined (e.g., page=1, limit=10) if the parameters are not provided in the request.
  • Implement a method to get the total number of team members available.

Purpose

Implementing pagination for the findAllTeamMembers endpoint will improve the performance and scalability of the application by reducing the amount of data retrieved from the database and transmitted over the network. This is especially important when dealing with a large number of team members.

Requirements

  • Modify the findAllTeamMembers method in TeamMemberController to accept optional page and limit query parameters.
  • Modify the findAllTeamMembers method in TeamMemberService to use the page and limit parameters to implement pagination using skip and take.
  • Update the API documentation (Swagger) to reflect the new page and limit parameters.
  • Ensure that the existing functionality of findAllTeamMembers remains intact when page and limit parameters are not provided.
  • Update DTOs to include the total number of team members found.

Test Evidence

Before fix

untested

After fix

tested

Expected Outcome

The findAllTeamMembers endpoint will return a paginated response with a subset of team members based on the page and limit parameters. The API documentation will be updated to reflect the new parameters, improving performance and scalability.

The JSON response should follow a uniform API format:

{
    "status": "success",
    "status_code": 200,
    "message": "Team members retrieved successfully",
    "data": {
        "team_members": [
            {
                "id": "123e4567-e89b-12d3-a456-426614174000",
                "name": "John Doe",
                "role": "Developer"
            },
            {
                "id": "89abcdef-9012-3456-7890-1234567890ab",
                "name": "Jane Smith",
                "role": "Designer"
            }
        ],
        "total": 150
    }
}

@TheCodeGhinux
Copy link
Contributor

What's this PR title?

@akinwalexander akinwalexander changed the title Find all team members pagination feat: find all team members pagination Feb 28, 2025
@akinwalexander akinwalexander changed the title feat: find all team members pagination feat: implement pagination for find all team members Feb 28, 2025
@akinwalexander akinwalexander changed the title feat: implement pagination for find all team members feat: implement pagination on find all team members Feb 28, 2025
@akinwalexander akinwalexander deleted the findAllTeamMembers-pagination branch February 28, 2025 21:29
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.

[FEAT]: Implement Pagination on findAllTeamMembers Endpoint
2 participants