Skip to content

Commit

Permalink
Merge pull request #1185 from weather-gov/mgwalker/alert-ids
Browse files Browse the repository at this point in the history
Fix how we id alerts
  • Loading branch information
greg-does-weather authored May 9, 2024
2 parents b2b37a2 + 4c48668 commit 5b75ba8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion tests/e2e/cypress/e2e/hourly-forecast-table.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe("Hourly forecast table tests", () => {
.contains("Red Flag Warning")
.invoke("attr", "aria-expanded")
.should("equal", "true");
cy.get("#alert_82d03a893a84390fbc5217471cd259eaa41a4135").should(
cy.get("#alert_82d03a893a84390fbc5217471cd259eaa41a4135_001_1").should(
"be.visible",
);
});
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/cypress/e2e/tabbed-nav.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ describe("<wx-tabbed-nav> component tests", () => {

describe("Initial page load with hash", () => {
it("Navigates to the correct alert accordion and opens it if hash present", () => {
const alertId = "alert_aa84ba418dfe6f3e1eb046cf9e4086aaaaddeb65";
const alertId = "alert_aa84ba418dfe6f3e1eb046cf9e4086aaaaddeb65_001_1";
cy.visit(`/point/34.749/-92.275#${alertId}`);
cy.get(`#${alertId}`)
.as("alertEl")
Expand Down
12 changes: 8 additions & 4 deletions web/modules/weather_data/src/Service/AlertTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,16 @@ public function getAlerts($grid, $point, $self = false, $now = false)
// https://oidref.com/2.49.0, and then
// http://www.oid-info.com/doc/introduction%20to%20object%20identifiers%20(OIDs)%20at%20WMO.pdf).
//
// The UUID uniquely identifies the alert, so we can use that. Not
// sure what the 001 and 0 parts of the OID are - updates, maybe?
// But not super relevant for us.
// The UUID uniquely identifies the alert and the .001.1 part
// uniquely identifies the alert.
//
// There's something funky that happens where a single alert can
// show up multiple times, but that's an issue upstream of us
// and for now, we can't really do anything about it.
$id = explode(".", $alert->properties->id);
$id = array_slice($id, -3);
$id = implode("_", $id);

$id = $id[count($id) - 3];
$output->alertId = $id;
} else {
// If it's not a NWS OID, just use the array index.
Expand Down

0 comments on commit 5b75ba8

Please sign in to comment.