Skip to content

Commit

Permalink
Merge pull request #1468 from weather-gov/mgwalker/1407-alert-list-re…
Browse files Browse the repository at this point in the history
…factor

Refactor alert metadata and add an alert metadata page
  • Loading branch information
greg-does-weather committed Jul 29, 2024
2 parents 02c3f48 + cecd26a commit 6a4c0e5
Show file tree
Hide file tree
Showing 9 changed files with 860 additions and 245 deletions.
26 changes: 26 additions & 0 deletions web/modules/weather_blocks/src/Plugin/Block/AlertInfoBlock.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Drupal\weather_blocks\Plugin\Block;

use Drupal\weather_data\Service\AlertUtility;
use Drupal\weather_data\Service\DateTimeUtility;

/**
* Provides a block of alert information
*
* @Block(
* id = "weathergov_info_alert",
* admin_label = @Translation("Alert info block"),
* category = @Translation("weather.gov"),
* )
*/
class AlertInfoBlock extends WeatherBlockBase
{
/**
* {@inheritdoc}
*/
public function build()
{
return ["alertTypes" => AlertUtility::getAlertTypes()];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace Drupal\weather_blocks\Plugin\Block\Test\EndToEnd;

use Drupal\weather_blocks\Plugin\Block\AlertInfoBlock;

/**
* Tests for alert info data structure.
*/
final class AlertInfoStructureTest extends EndToEndBase
{
/**
* Create the block under test.
*/
protected function setUp($type = null): void
{
parent::setUp(AlertInfoBlock::class);
}

/**
* Simply validate the data structure.
* @group e2e
*/
public function testAlertDataStructure(): void
{
$schema = SchemaHelper::load("alertInfo.json");

$data = $this->block->build();
$schema->in($data["alertTypes"]);

$this->assertTrue(true);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"type": "array",
"items": {
"type": "object",
"properties": {
"alert": {
"type": "string"
},
"kind": { "type": "string" },
"level": { "type": "string" },
"priority": { "type": "number" }
}
}
}
2 changes: 1 addition & 1 deletion web/modules/weather_data/src/Service/AlertTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function getAlerts($grid, $point, $self = false, $now = false)
$fireZone,
$now,
) {
if (AlertUtility::isMarineAlert($alert->properties->event)) {
if (!AlertUtility::isLandAlert($alert->properties->event)) {
return false;
}

Expand Down
Loading

0 comments on commit 6a4c0e5

Please sign in to comment.