Yu Yan - feat: add reasons array to infringements in user profile (resolves #1686, #1817)#2106
Open
yany960 wants to merge 12 commits intodevelopmentfrom
Open
Yu Yan - feat: add reasons array to infringements in user profile (resolves #1686, #1817)#2106yany960 wants to merge 12 commits intodevelopmentfrom
yany960 wants to merge 12 commits intodevelopmentfrom
Conversation
- Add reasons field to infringement schema with enum validation - Supported values: 'time not met', 'missing summary', 'missed video call', 'late reporting', 'other' - Default value: ['other'] - Process reasons array in addInfringements controller: - Normalize to lowercase - Deduplicate values - Filter valid enum values only - Default to ['other'] if empty - Maintain backward compatibility with existing reason field - Resolves merge conflicts from PR #1686 and #1817
- Add schema validation tests for reasons field - Add processing logic tests (lowercase, deduplication, filtering) - Add edge case tests (empty strings, special characters, large arrays) - Add backward compatibility tests - Add date validation tests
…tion in tests - Move processReasons function to top-level describe block - Remove 3 duplicate function definitions from Edge Cases tests - Fix SonarCloud duplicated lines issue (22.3% -> 0%) - All 18 tests still passing
- Add 'manullyAssigned', 'manullyAssignedBy', and 'editedBy' fields to infringement schema - Track when blue squares are manually assigned vs CRON job assigned - Record edit history with user info and timestamp - Set reasons array for CRON-assigned blue squares based on violation type - Update addInfringements to populate manual assignment fields - Update editInfringements to track edit history - Update assignBlueSquareForTimeNotMet for CRON job assignments
4 tasks
Anusha-Gali
requested changes
Apr 1, 2026
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



Description
This PR adds a
reasonsarray to infringements in the user profile, allowing for more robust and flexible categorization of issues such as "time not met," "missing summary," "missed video call," "late reporting," or "other."The controller logic ensures reasons are consistently handled as a lowercased, deduplicated array with a safe default, which both improves data quality and simplifies future analytics or display logic.
Fixes #1686, #1817 (PRIORITY HIGH)

This is a redo PR:
Related PRS (if any):
PR 1686 - Original PR by Yu Yan taking over for Ujjwal
PR 1817 - Attempt to resolve merge conflicts
Main changes explained:
Added functionality to easily parse reasons for Blue Squares using a reasons array. Added the reasons array field to store multiple categorization reasons for each infringement.
Added
reasonsfield underinfringementsinuserProfilemodel with predefined options (which can be modified as required)['other']'time not met','missing summary','missed video call','late reporting','other'Updated
addInfringementscontroller logic to:['other']if empty or invalidMaintains backward compatibility with existing
reason(single string) fieldHow to test:
feat/infringement-reasons-arraynpm run buildandnpm startto run this PR locallyapi/userProfile/:userId/addInfringementto add an infringementExample request body:
{ "requestor": "<your-user-id>", "blueSquare": { "date": "2025-09-03", "description": "PR Testing Add Infringement", "reasons": ["time not met", "missing summary", "missed video call", "late reporting", "other"] } }