Skip to content

fix: improve spp_hazard performance, security, UX, and test coverage #101

Open
gonzalesedwin1123 wants to merge 2 commits into19.0from
fix/spp-hazard-review-fixes
Open

fix: improve spp_hazard performance, security, UX, and test coverage #101
gonzalesedwin1123 wants to merge 2 commits into19.0from
fix/spp-hazard-review-fixes

Conversation

@gonzalesedwin1123
Copy link
Member

Summary

  • Fix performance issues in computed fields (replace len(rec.xxx_ids) with read_group, use SQL COUNT(DISTINCT) for affected registrant counts, batch bulk_create_impacts with BATCH_SIZE=500)
  • Fix security: restrict officer write/create on config models (category, impact_type), add base.group_user read ACL for spp.hazard.impact
  • Fix Odoo 19 compatibility: replace deprecated name_get() with _compute_display_name(), use Command.link() in tests
  • Fix action_close() multi-record bug (now iterates per record)
  • Improve UX: apply master data vs workflow entity form patterns, add alert banners, badge decorations, accessibility titles, extension points
  • Add demo data: 3 areas, 3 registrants, 5 impact records with mixed verification statuses
  • Add 21 new tests (registrant: 9, security: 7, incident: 5) bringing total to 59 passing tests with 100% method/field/constraint coverage
  • Add USAGE.md QA testing guide (13 sections, 487 lines) and update DESCRIPTION.md

Test plan

  • All 59 tests pass (./scripts/test_single_module.sh spp_hazard)
  • All pre-commit hooks pass (ruff, pylint, prettier, oca-gen-addon-readme, OpenSPP custom checks)
  • 100% coverage of public methods, computed fields, and constraints
  • Security tested for all 3 roles (viewer, officer, manager)
  • Manual QA: install with demo data, verify menu structure and form layouts
  • Manual QA: verify officer cannot write/create categories or impact types
  • Manual QA: verify registrant Emergency Response tab and stat button

- Replace len(rec.xxx_ids) with read_group for computed counts
- Use SQL COUNT(DISTINCT) for affected_registrant_count
- Batch bulk_create_impacts with BATCH_SIZE=500
- Replace deprecated name_get() with _compute_display_name()
- Fix action_close() multi-record bug (iterate per record)
- Restrict officer write/create on config models (category, impact_type)
- Add base.group_user read ACL for spp.hazard.impact
- Apply master data vs workflow entity form patterns
- Add alert banners, badge decorations, extension points
- Add accessibility titles to icon elements
- Add demo areas, registrants, and impact records
- Add registrant test suite (9 tests) and security tests (7 tests)
- Add 5 new incident tests (areas, display_name, constraints, close)
- Update DESCRIPTION.md and add USAGE.md QA testing guide
@gemini-code-assist
Copy link

Warning

Gemini is experiencing higher than usual traffic and was unable to create the summary. Please try again in a few hours by commenting /gemini summary.

@codecov
Copy link

codecov bot commented Mar 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.20%. Comparing base (9c2376e) to head (de35ee4).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             19.0     #101      +/-   ##
==========================================
+ Coverage   71.17%   71.20%   +0.03%     
==========================================
  Files         704      704              
  Lines       38554    38565      +11     
==========================================
+ Hits        27439    27462      +23     
+ Misses      11115    11103      -12     
Flag Coverage Δ
spp_api_v2_gis 71.52% <ø> (ø)
spp_base_common 90.26% <ø> (ø)
spp_dci_demo 69.23% <ø> (ø)
spp_drims 79.55% <ø> (ø)
spp_drims_sl_demo 68.33% <ø> (-0.58%) ⬇️
spp_gis_indicators 91.07% <ø> (ø)
spp_hazard 99.57% <100.00%> (+7.06%) ⬆️
spp_hazard_programs 97.14% <ø> (ø)
spp_hxl_area 63.74% <ø> (ø)
spp_mis_demo_v2 69.82% <ø> (ø)
spp_programs 45.51% <ø> (ø)
spp_security 66.66% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
spp_hazard/models/hazard_category.py 100.00% <100.00%> (ø)
spp_hazard/models/hazard_impact.py 100.00% <100.00%> (ø)
spp_hazard/models/hazard_impact_type.py 100.00% <100.00%> (ø)
spp_hazard/models/hazard_incident.py 100.00% <100.00%> (+12.34%) ⬆️
spp_hazard/models/registrant.py 100.00% <100.00%> (+24.00%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Cover gaps in hazard_incident.py: is_ongoing for alert/recovery/closed
statuses, date constraint on update, DISTINCT registrant counting,
empty recordset branch, multi-record action_close, and end_date
preservation on close. Total tests: 59 → 65.
@gonzalesedwin1123 gonzalesedwin1123 marked this pull request as ready for review March 12, 2026 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant