Incidents Backend Refactor #164
Open
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.
The current system tracks complaints as their own table while warnings and citations are stored as integer counters on the Location entity. This creates inconsistency in how we track incidents and makes it difficult to view the history or details of individual warnings/citations. This PR consolidates all three incident types into a single Incidents table with a severity field.
Changes:
New Incident Module
incident_entity.py,incident_model.py,incident_service.py, andincident_router.pyto replace the complaint moduleIncidentSeverityenum with values:complaint,warning,citationseverityfield to incident data model and entityLocation Entity Updates
warning_countandcitation_countcolumns since these are now derived from the incidents tablecomplaintsrelationship toincidentsLocationDtoto returnincidentslist instead ofcomplaintsMAX_COUNTconstant and count validation logicRemoved Increment Routes
POST /api/police/locations/{id}/warningsandPOST /api/police/locations/{id}/citationsendpointspolice_router.pysince police credential routes live inaccount_router.pyincrement_warnings()andincrement_citations()methods fromLocationServiceTest Updates
incident_utils.py,incident_service_test.py,incident_router_test.py)Script Updates
reset_dev.pyto removewarning_countandcitation_countfrom location seedingCursor was helpful with making these changes, but I reviewed all AI-made changes prior to committing the code.
Closes #127