Skip to content

Commit 80e28c5

Browse files
committed
fixup! feat(cyclone): update the episode logic in gdacs cyclone.
1 parent 446ad41 commit 80e28c5

3 files changed

Lines changed: 14 additions & 10 deletions

File tree

alert_system/etl/base/extraction.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -267,18 +267,22 @@ def _impact_filter(self, impact_metadata: list[dict]) -> str:
267267
filters = []
268268

269269
for data in impact_metadata or []:
270+
category = data.get("category")
271+
impact_type = data.get("type")
272+
value = data.get("value")
273+
270274
if (
271-
data.get("category") == ImpactDetailsEnum.Category.PEOPLE
272-
and data.get("type") == ImpactDetailsEnum.Type.AFFECTED_TOTAL # TODO: Add other possible types here.
273-
and data.get("value") is not None
275+
category == ImpactDetailsEnum.Category.PEOPLE
276+
and impact_type == ImpactDetailsEnum.Type.AFFECTED_TOTAL
277+
and value is not None
278+
and value > 0
274279
):
275-
value = data["value"]
276280
lower_bound = 10 ** (math.floor(math.log10(value)) - 1)
277281
upper_bound = 10 ** (math.floor(math.log10(value)) + 1)
278282

279283
filters.append(
280-
f"monty:impact_detail.category = '{data['category']}' AND "
281-
f"monty:impact_detail.type = '{data['type']}' AND "
284+
f"monty:impact_detail.category = '{category}' AND "
285+
f"monty:impact_detail.type = '{impact_type}' AND "
282286
f"monty:impact_detail.value >= {lower_bound} AND "
283287
f"monty:impact_detail.value <= {upper_bound}"
284288
)

alert_system/migrations/0001_initial.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Generated by Django 4.2.30 on 2026-05-18 06:09
1+
# Generated by Django 4.2.30 on 2026-05-18 09:45
22

33
from django.conf import settings
44
import django.contrib.postgres.fields
@@ -11,8 +11,8 @@ class Migration(migrations.Migration):
1111
initial = True
1212

1313
dependencies = [
14+
('api', '0231_alter_export_export_type'),
1415
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
15-
('api', '0227_alter_eventseveritylevelhistory_options'),
1616
('notifications', '0016_alertsubscription'),
1717
]
1818

@@ -73,7 +73,7 @@ class Migration(migrations.Migration):
7373
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
7474
('extraction_run_id', models.UUIDField(blank=True, db_index=True, help_text='UUID field for tracking the extraction run through ETL pipeline', null=True)),
7575
('created_at', models.DateTimeField(auto_now_add=True, help_text='Timestamp when the record was created', verbose_name='Created At')),
76-
('collection', models.CharField(choices=[('event', 'event'), ('hazard', 'Hazard'), ('impact', 'Impacts')], help_text='Collection type of the item', verbose_name='Collection')),
76+
('collection', models.CharField(choices=[('event', 'Event'), ('hazard', 'Hazard'), ('impact', 'Impacts')], help_text='Collection type of the item', verbose_name='Collection')),
7777
('stac_id', models.CharField(db_index=True, help_text='Unique identifier for the event item', max_length=255, unique=True, verbose_name='Event ID')),
7878
('resp_data', models.JSONField(blank=True, help_text='Raw JSON response from the STAC API', null=True, verbose_name='Response Data')),
7979
('connector', models.ForeignKey(help_text='Data source connector', on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_items', to='alert_system.connector', verbose_name='Connector')),

alert_system/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ class ExtractionItem(BaseItem):
146146
"""
147147

148148
class CollectionType(models.TextChoices):
149-
EVENT = "event", _("event")
149+
EVENT = "event", _("Event")
150150
HAZARD = "hazard", _("Hazard")
151151
IMPACT = "impact", _("Impacts")
152152

0 commit comments

Comments
 (0)