Add v4 property column stats API#5262
Conversation
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR replaces the v4 analyses stats endpoint with a new v4 properties/column_summary endpoint that returns richer per-column inventory statistics (including numeric aggregates, distribution stats, and unit metadata), and incorporates the referenced migration/order-determinism fixes.
Changes:
- Removed
v4/analysesand addedv4/propertieswith a newcolumn_summaryaction for column-level stats (including optional raw data). - Added deterministic tie-break ordering (
id) to several “latest/ordered” queries to prevent nondeterministic results on timestamp ties. - Added/updated repair migrations to restore missing PK/unique constraints for production DBs; updated Angular static-file serving fallback paths.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| seed/views/v4/taxlot_properties.py | Adds license header. |
| seed/views/v4/property.py | New v4 properties API with column_summary stats endpoint. |
| seed/views/v4/organization_users.py | Adds license header. |
| seed/views/v4/analyses.py | Removes old v4 analyses stats endpoint. |
| seed/api/v4/urls.py | Removes analyses route; registers properties route. |
| seed/tests/v4/test_analyses_views.py | Updates v4 tests to cover properties-column-summary behavior. |
| seed/views/v3/properties.py | Makes “latest file” selection deterministic on created ties. |
| seed/views/v3/events.py | Makes event ordering deterministic on created ties. |
| seed/utils/tax_lot_properties.py | Makes note ordering deterministic on created ties. |
| seed/utils/public.py | Makes public feed ordering deterministic on updated ties. |
| seed/utils/match.py | Makes match-merge ordering deterministic on updated ties. |
| seed/models/properties.py | Makes audit-log selection deterministic (but still needs a None-guard fix). |
| seed/models/tax_lots.py | Makes audit-log selection deterministic (but still needs a None-guard fix). |
| seed/models/certification.py | Makes “previous log” selection deterministic on created ties. |
| seed/migrations/0250_remove_goal_current_cycle_goal_partner_note_and_more.py | Adds guarded constraint-repair SQL before existing operations. |
| seed/migrations/0254_repair_referenced_primary_keys.py | Adds follow-up guarded constraint-repair migration for already-migrated DBs. |
| seed/lib/superperms/orgs/migrations/0046_repair_organizationuser_constraints.py | Adds guarded constraint-repair migration in orgs app. |
| ng_seed/views.py | Adjusts Angular static-file serving to check additional build output paths (needs path traversal hardening). |
| .spelling.dic | Adds new dictionary entries (one appears to include an unintended trailing quote). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| for selected_cycle_id in selected_cycle_ids: | ||
| property_views_qs = _build_property_views_queryset(org_id, self.request.access_level_instance_id, [selected_cycle_id]) | ||
| state_ids = list(property_views_qs.values_list("state_id", flat=True)) |
There was a problem hiding this comment.
Fixed in commit where _build_property_views_queryset now accepts an AccessLevelInstance object directly (instead of fetching by ID), and the instance is fetched once before the cycle loop in column_summary.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Any background context you want to provide?
Inventory has a summary page which showed the count of entries in each field. More stats would be useful to really understand what data are in a SEED org's inventory.
What's this PR do?
This PR currently includes updated from the
fix-migrationsPR #5261How should this be manually tested?
Launch with SEED-platform/seed-angular#70 and go to inventory summary.
What are the relevant tickets?
Screenshots (if appropriate)