Skip to content

Conversation

@bernhaaard
Copy link
Contributor

  • Changed supervision requests count endpoint to accept any request state.
  • Route updated from /pending-count/:userId to /count/:userId with required request_state query parameter.
  • Enables counting of PENDING, ACCEPTED, REJECTED, or WITHDRAWN requests instead of only pending ones.

📝 Example Usage

# Get pending requests for a user
GET /supervision-requests/count/{userId}?request_state=PENDING

# Get accepted requests for a user
GET /supervision-requests/count/{userId}?request_state=ACCEPTED

# Response format
{
  "request_count": 5
}

Copilot AI review requested due to automatic review settings June 19, 2025 22:45
@bernhaaard bernhaaard requested a review from jb-cc as a code owner June 19, 2025 22:45

This comment was marked as outdated.

@bernhaaard bernhaaard changed the base branch from main to dev June 19, 2025 22:48
@bernhaaard bernhaaard force-pushed the SCRUM-XXX-add-request-state-param-to-count-supervision-requests branch from 64955b9 to 81f725e Compare June 19, 2025 22:48
@bernhaaard bernhaaard requested a review from Copilot June 19, 2025 22:53
Changed supervision requests count endpoint to accept any request state.
Route updated from /pending-count/:userId to /count/:userId with required
request_state query parameter. Enables counting of PENDING, ACCEPTED,
REJECTED, or WITHDRAWN requests instead of only pending ones.
@bernhaaard bernhaaard force-pushed the SCRUM-XXX-add-request-state-param-to-count-supervision-requests branch from 3d2fe22 to 010a19d Compare June 19, 2025 22:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

The PR generalizes the supervision requests count endpoint to accept a request_state filter, replacing the previous hardcoded pending-only count.

  • Renames and parameterizes the service method and return entity to handle any RequestState
  • Updates the controller route, DTO, Swagger docs, and OpenAPI spec to require a request_state query parameter
  • Refactors and extends tests to cover multiple states and removes the old pending-only entity

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
supervision-requests.service.ts Renamed method/entity, added requestState parameter, updated return shape
supervision-requests.service.spec.ts Updated tests to call new method with different states
supervision-requests.controller.ts Changed route and method name, added DTO and @ApiQuery
supervision-requests.controller.spec.ts Updated controller tests for new query parameter
supervision-request-count.entity.ts Added new SupervisionRequestCountEntity
pending-request-count.entity.ts Removed old pending-only entity contents
dto/count-query.dto.ts Introduced CountQueryDto for validating request_state
OpenAPI.json Updated path, parameters, response schema, and component names
Comments suppressed due to low confidence (3)

backend/src/modules/requests/supervision/supervision-requests.controller.spec.ts:384

  • Add tests for cases where the request_state query parameter is missing or invalid to ensure the controller returns a 400 Bad Request with the appropriate validation error.
  describe('getRequestCountForUser', () => {

backend/src/modules/requests/supervision/supervision-requests.service.ts:319

  • Ensure that the RequestState enum is imported at the top of this file (e.g. import { RequestState } from '@prisma/client';) to prevent compile errors.
    requestState: RequestState,

@bernhaaard bernhaaard self-assigned this Jun 19, 2025
@jb-cc
Copy link
Contributor

jb-cc commented Jun 19, 2025

@nb159 use this via the proxy for now, as the nuxt api endpoint does not exist yet (I will tell you when its there)

@jb-cc jb-cc merged commit 25ccfe8 into dev Jun 19, 2025
2 checks passed
@jb-cc jb-cc deleted the SCRUM-XXX-add-request-state-param-to-count-supervision-requests branch June 19, 2025 22:57
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.

3 participants