Skip to content

Conversation

@bkarimii
Copy link
Owner

Naming Rules

Name your PR like this: ISSUENUMBER-TITLE-YOURNAME

Description

Summary:
This PR improves the /users/status-counts API endpoint to provide a more meaningful overview of user activity by:

  • Normalising user activity scores using the configured thresholds, allowing fairer comparisons between users with different activity levels.

  • Returning structured user status counts as an object (inactive, low, medium, high) for easier frontend interpretation and analytics.

  • Including box plot data (min, q1, median, q3, max, outliers) using the new getBoxPlotData() utility function, to give admins statistical insight into the distribution of user scores.

Breakdown of Changes:
Refactored API logic to:

Fetch user activity and configuration thresholds from the database.

Normalise scores using the scoreNormaliser function.

Generate box plot data using getBoxPlotData.

Determine status counts using decideStatus.

Response structure now includes:

{
"status": {
"inactive": 3,
"low": 7,
"medium": 12,
"high": 4
},
"scores": {
"min": 0,
"q1": 20,
"median": 45,
"q3": 70,
"max": 95,
"outliers": [13]
}
}

@bkarimii bkarimii merged commit 73aedc6 into staging Apr 25, 2025
5 checks passed
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