Skip to content

Admin - user request optimal #201

@knightempire

Description

@knightempire

Issue: Create API to Fetch Requests Optimally

Description

Develop a new API endpoint to optimally fetch requests, using logic based on the existing fetchUserRequests function. The new function should be named fetchUserRequestsOptimal. It must include pagination (5 items per page) and support filtering via query parameters.

Requirements

  • Function Name: fetchUserRequestsOptimal
  • API Endpoint: /api/request/user-get/optimal/:id
  • HTTP Method: GET

Query Parameters

Parameter Type Required Description
page Number No Page number for pagination (default: 1)
status String No Filter by request status (e.g., pending, approved)
products String No Filter by product(s). Accepts comma-separated values.

Pagination

  • Page size is fixed to 5 requests per page.

Response

The API should return a JSON object containing:

  • data: List of requests matching the filters
  • pagination:
    • totalRequests: Total number of matching requests
    • totalPages: Total pages available
    • currentPage: Current page number
  • filtersApplied: An object showing active filters (if any)

Example Successful Response

{
  "data": [
    {
      "id": "REQ123",
      "status": "approved",
      "products": ["productA"]
    },
    ...
  ],
  "pagination": {
    "totalRequests": 17,
    "totalPages": 4,
    "currentPage": 2
  },
  "filtersApplied": {
    "status": "approved",
    "products": ["productA", "productB"]
  }
}

Metadata

Metadata

Assignees

Labels

ContollersWrite or update the controllersoptimaloptimal solutionv1.1Version

Projects

Status

In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions