Skip to content

Add GET /api/v1/users/guards/{id}/score performance scoring endpoint#360

Open
ajablaza wants to merge 1 commit intomainfrom
ajablaza/feature/guard-score
Open

Add GET /api/v1/users/guards/{id}/score performance scoring endpoint#360
ajablaza wants to merge 1 commit intomainfrom
ajablaza/feature/guard-score

Conversation

@ajablaza
Copy link
Copy Markdown
Collaborator

@ajablaza ajablaza commented May 8, 2026

feat: Add GET /api/v1/users/guards/{id}/score performance scoring endpoint

Summary

Adds a new endpoint that returns a composite performance score (0–100) for a given guard, calculated from three weighted dimensions: punctuality, shift completion, and incident reports.

Endpoint

GET /api/v1/users/guards/{id}/score


Scoring Breakdown

Punctuality — 35 pts max

Calculated as (on-time check-ins / total shifts) * 35. A guard who checks in on time for every shift scores the full 35.

Shift Completion — 35 pts max

Calculated as (completed shifts / total shifts) * 35. Reflects reliability in seeing shifts through to the end.

Incident Reports — 30 pts max (deductions)

Starts at 30 and deducts based on incident severity:

Severity Deduction
High −5 pts
Medium −2 pts
Low −1 pt

The deduction is calculated as:
deduction = (weightedIncidentSum / totalAssigned) × 10
incidentScore = max(0, 30 − deduction)


Notes

  • Returns a single integer score in the range 0–100
  • All three components are calculated at query time from existing shift and incident report data — no score persistence needed unless caching is later deemed necessary
  • Edge case: guard with no shifts yet return a default value(null)

Postman Testing

image image image

@ajablaza ajablaza requested a review from uppalkrish May 8, 2026 18:31
@uppalkrish
Copy link
Copy Markdown
Collaborator

Show the api running on swagger

@ajablaza
Copy link
Copy Markdown
Collaborator Author

ajablaza commented May 8, 2026

Done @uppalkrish
image

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.

2 participants