Cs/ccct 2283 coverage area calculation update#1138
Conversation
0e22125 to
8665c2c
Compare
pxwxnvermx
left a comment
There was a problem hiding this comment.
Couple of questions regarding clustering.
- Do the excluded work areas still remain a part of the work area group that was assigned to them during clustering?
- Can a work area be excluded before the clustering is run? If yes, should that work area be excluded from the clustering?
f5e99f6 to
8665c2c
Compare
I think so? Let me confirm.
Not as far as I'm aware, but I'll check as well. |
See 9460268
Confirmed for now it will be. |
| slug="excluded-area", | ||
| ward="ward-1", |
There was a problem hiding this comment.
Minor nit: Since these values aren't being tested anywhere these fields can safely be removed as they get given defaults by the factory.
Product Description
When a work area is excluded from a microplanning opportunity, it is now consistently treated as non-existent across all coverage calculations and exports:
excluded work areas.
expected_visit_counton an excluded work area is set to zero atthe time of exclusion.
Technical Summary
Link to ticket here
This is a release path 3 feature — Experiments & early stage iterations of
product area
Three related gaps were closed to make excluded work areas invisible to
coverage-area calculations:
WorkAreaGroup.building_count(models.py): Thecached_propertynowfilters out
WorkAreaStatus.EXCLUDEDwork areas before summingbuilding_count, so group-level totals reflect only active areas.download_work_areasview (views.py): The base queryset for the CSVexport now excludes work areas with
EXCLUDEDstatus before passing toWorkAreaMapFilterSet, so excluded areas never appear in downloads.exclude_work_areasview (views.py): When a work area is excluded,expected_visit_countis set to0and included inupdate_fields,ensuring the visit target is zeroed out at exclusion time.
Safety Assurance
Safety story
Changes are isolated to read paths (queryset filtering, property aggregation)
and a single extra field write during the existing exclusion flow. No
migrations are required. Excluded work areas already had their
work_area_groupnulled out; this PR extends that same cleanup logic toexpected_visit_countand to the two remaining read surfaces. Existingexcluded records will have their
expected_visit_countcorrected the nexttime they are excluded (no backfill needed for historical data since this is
an early-stage feature).
Automated test coverage
TestWorkAreaGroupBuildingCount(tests/test_models.py) — threecases: sums non-excluded areas, ignores excluded areas, returns zero when all
excluded.
TestDownloadWorkAreas.test_excludes_excluded_work_areas(
tests/test_views.py) — verifies excluded work areas are absent from theCSV download.
TestExcludeWorkAreas(tests/test_views.py) — extended with anassertion that
expected_visit_count == 0after exclusion.QA Plan
N.A
Labels & Review
risk of the change