-
Notifications
You must be signed in to change notification settings - Fork 5
feat(spp_hazard): CAP vocabulary severity and alert ingestion, with upgrade migration (re-land from #76) #274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
gonzalesedwin1123
wants to merge
10
commits into
19.0
Choose a base branch
from
reland/hazard-cap
base: 19.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a4dd8e8
feat(spp_hazard): re-land CAP vocabulary severity with upgrade migrat…
gonzalesedwin1123 8a74908
fix: address CI findings — psycopg2.sql composition in migration, reg…
gonzalesedwin1123 f0b7352
style: align README rendering and test formatting with CI
gonzalesedwin1123 84b3573
style: suppress pylint-odoo sql-injection false positive in migration
gonzalesedwin1123 2cf94bb
refactor: literal parameterized SQL in severity migration
gonzalesedwin1123 7f5520c
docs(spp_hazard): use CI's pinned renderer output for README/index.html
gonzalesedwin1123 ed7d0e5
docs: align base README rendering with CI generator on this ref
gonzalesedwin1123 4bf883d
fix(spp_hazard): address gemini-code-assist review findings
gonzalesedwin1123 fa7bd72
feat(spp_hazard): add severity_numeric bridge and document breaking c…
kneckinator 32e43ad
chore(spp_hazard): bump to 19.0.3.0.0 (major) for breaking severity c…
kneckinator File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,7 @@ | ||
| ### 19.0.2.1.0 | ||
|
|
||
| - feat: incident areas expose `effective_severity_id` (area override or incident severity) and a numeric 1-5 `severity_numeric` derived from CAP severity codes for choropleth visualization (re-land from #76, follows the spp_hazard severity vocabulary change). | ||
|
|
||
| ### 19.0.2.0.0 | ||
|
|
||
| - Initial migration to OpenSPP2 |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| # Part of OpenSPP. See LICENSE file for full copyright and licensing details. | ||
| from .common import DrimsTestCommon | ||
|
|
||
|
|
||
| class TestIncidentAreaSeverity(DrimsTestCommon): | ||
| """Effective severity / numeric severity for the GIS choropleth. | ||
|
|
||
| Guards the spp_hazard severity migration (Selection -> CAP vocabulary | ||
| Many2one): spp_drims extends spp.hazard.incident.area and must follow the | ||
| new severity_id / severity_override_id fields. | ||
| """ | ||
|
|
||
| @classmethod | ||
| def setUpClass(cls): | ||
| super().setUpClass() | ||
| VocabCode = cls.env["spp.vocabulary.code"] | ||
| ns = "urn:oasis:names:tc:cap:severity" | ||
| cls.sev_extreme = VocabCode.get_code(ns, "extreme") | ||
| cls.sev_severe = VocabCode.get_code(ns, "severe") | ||
| cls.sev_moderate = VocabCode.get_code(ns, "moderate") | ||
|
|
||
| def _make_area(self, severity_override_id=False): | ||
| return self.env["spp.hazard.incident.area"].create( | ||
| { | ||
| "incident_id": self.incident.id, | ||
| "area_id": self.area.id, | ||
| "severity_override_id": severity_override_id, | ||
| } | ||
| ) | ||
|
|
||
| def test_effective_severity_uses_override(self): | ||
| """Area override takes precedence over the incident severity.""" | ||
| self.incident.severity_id = self.sev_moderate | ||
| area = self._make_area(severity_override_id=self.sev_extreme.id) | ||
| self.assertEqual(area.effective_severity_id, self.sev_extreme) | ||
| self.assertEqual(area.severity_numeric, 5) | ||
|
|
||
| def test_effective_severity_falls_back_to_incident(self): | ||
| """Without an override, severity is inherited from the incident.""" | ||
| self.incident.severity_id = self.sev_severe | ||
| area = self._make_area() | ||
| self.assertEqual(area.effective_severity_id, self.sev_severe) | ||
| self.assertEqual(area.severity_numeric, 4) | ||
|
|
||
| def test_severity_numeric_zero_when_unset(self): | ||
| """No override and no incident severity -> numeric 0 (no choropleth value).""" | ||
| self.incident.severity_id = False | ||
| area = self._make_area() | ||
| self.assertFalse(area.effective_severity_id) | ||
| self.assertEqual(area.severity_numeric, 0) |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,7 @@ | ||
| ### 19.0.2.0.1 | ||
|
|
||
| - fix: demo generator resolves scenario severity levels to CAP severity vocabulary codes (follows the spp_hazard severity vocabulary change, re-land from #76). | ||
|
|
||
| ### 19.0.2.0.0 | ||
|
|
||
| - Initial migration to OpenSPP2 |
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟠 This legacy 1→5 → CAP mapping diverges from the migration's
spp_hazard/migrations/19.0.2.1.0/post-migration.pymaps the same legacy scale differently:They only agree on 4 and 5. So a "level 3" incident becomes CAP severe on an upgraded DB but CAP moderate on a fresh demo install — and
2→minor/3→moderatehere also contradicts the original Selection labels. Recommend reconciling to the migration's label-faithful mapping, or adding a comment justifying why the demo path intentionally differs (it round-trips withspp_drims'sCAP_SEVERITY_NUMERIC).