Endpoint Update: /users/status-counts Enhancement - BEHROUZ #123
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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]
}
}