Skip to content

Commit 9fd5372

Browse files
committed
chore(alert-system): clean up naming and cronjobs
1 parent 04fcdea commit 9fd5372

File tree

9 files changed

+58
-23
lines changed

9 files changed

+58
-23
lines changed

alert_system/admin.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from django.contrib import admin
22

3-
from .models import Connector, ExtractionItem, LoadItems
3+
from .models import Connector, ExtractionItem, LoadItem
44

55

66
@admin.register(Connector)
@@ -25,8 +25,8 @@ class EventAdmin(admin.ModelAdmin):
2525
)
2626

2727

28-
@admin.register(LoadItems)
29-
class LoadAdmin(admin.ModelAdmin):
28+
@admin.register(LoadItem)
29+
class LoadItemAdmin(admin.ModelAdmin):
3030
list_display = (
3131
"id",
3232
"event_title",

alert_system/etl/Gdacs_flood/transform.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,19 @@ class GdacsTransformer(BaseTransformerClass):
2525

2626
# NOTE: This logic might change in future
2727
def compute_people_exposed(self, metadata_list) -> int:
28-
for m in metadata_list:
29-
if m["category"] == "people" and m["type"] == "affected_total":
30-
return m["value"]
28+
for data in metadata_list:
29+
if data["category"] == "people" and data["type"] == "affected_total":
30+
return data["value"]
3131
return 0
3232

3333
# NOTE: This logic might change in future
3434
def compute_buildings_exposed(self, metadata_list) -> int:
3535
"""
3636
Compute the 'buildings_exposed' field.
3737
"""
38-
for m in metadata_list:
39-
if m["category"] == "buildings" and m["type"] == "damaged":
40-
return m["value"]
38+
for data in metadata_list:
39+
if data["category"] == "buildings" and data["type"] == "damaged":
40+
return data["value"]
4141
return 0
4242

4343
def process_impact(self, impact_items) -> BaseTransformerClass.ImpactType:

alert_system/etl/base/extraction.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import httpx
88
from django.db import transaction
99

10-
from alert_system.models import Connector, ExtractionItem, LoadItems
10+
from alert_system.models import Connector, ExtractionItem, LoadItem
1111

1212
from .loader import BaseLoaderClass
1313
from .transform import BaseTransformerClass
@@ -258,14 +258,14 @@ def fetch_past_events(self, load_obj):
258258
continue
259259

260260
# Past event already exists → attach it
261-
if LoadItems.objects.filter(correlation_id=corr_id).exists():
262-
related_ids.append(LoadItems.objects.get(correlation_id=corr_id).id)
261+
if LoadItem.objects.filter(correlation_id=corr_id).exists():
262+
related_ids.append(LoadItem.objects.get(correlation_id=corr_id).id)
263263
continue
264264

265265
# Otherwise extract + load it as past event
266266
self.run(correlation_id=corr_id, is_past_event=True)
267267

268-
related_event_obj = LoadItems.objects.filter(correlation_id=corr_id).first()
268+
related_event_obj = LoadItem.objects.filter(correlation_id=corr_id).first()
269269

270270
if related_event_obj:
271271
related_ids.append(related_event_obj.id)

alert_system/etl/base/loader.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from abc import ABC, abstractmethod
33
from typing import Dict
44

5-
from alert_system.models import Connector, LoadItems
5+
from alert_system.models import Connector, LoadItem
66

77
logger = logging.getLogger(__name__)
88

@@ -18,7 +18,7 @@ def filter_eligible_items(self, load_obj):
1818
# def fetch_similar_past_events(self, load_obj):
1919
# raise NotImplementedError()
2020

21-
def load(self, transformed_data: Dict, connector: Connector, is_past_event: bool = False) -> LoadItems:
21+
def load(self, transformed_data: Dict, connector: Connector, is_past_event: bool = False) -> LoadItem:
2222
"""
2323
Save aggregated event.
2424
@@ -32,7 +32,7 @@ def load(self, transformed_data: Dict, connector: Connector, is_past_event: bool
3232
correlation_id = transformed_data["correlation_id"]
3333
is_item_eligible = self.filter_eligible_items(transformed_data)
3434

35-
load_obj, created = LoadItems.objects.update_or_create(
35+
load_obj, created = LoadItem.objects.update_or_create(
3636
correlation_id=correlation_id,
3737
defaults={
3838
"connector": connector,
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 4.2.26 on 2025-12-07 16:19
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('alert_system', '0002_loaditems_is_past_event_loaditems_related_events'),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name='extractionitem',
15+
name='collection',
16+
field=models.IntegerField(choices=[(100, 'event'), (200, 'Hazard'), (300, 'Impacts')], help_text='Collection type of the item', verbose_name='Collection'),
17+
),
18+
]
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Generated by Django 4.2.26 on 2025-12-07 17:36
2+
3+
from django.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('alert_system', '0003_alter_extractionitem_collection'),
10+
]
11+
12+
operations = [
13+
migrations.RenameModel(
14+
old_name='LoadItems',
15+
new_name='LoadItem',
16+
),
17+
]

alert_system/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def __str__(self):
109109
return self.stac_id
110110

111111

112-
class LoadItems(BaseItem):
112+
class LoadItem(BaseItem):
113113
"""
114114
Model for Load items.
115115
"""

deploy/helm/ifrcgo-helm/values.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,11 +275,11 @@ cronjobs:
275275
- command: 'ingest_icrc'
276276
schedule: '0 3 * * 0'
277277
# Schedule time yet to be decided
278-
- command: 'poll_gdacs_cy'
278+
- command: 'poll_gdacs_cyclone'
279279
schedule: '0 0 * * 0'
280-
- command: 'poll_gdacs_fl'
280+
- command: 'poll_gdacs_flood'
281281
schedule: '0 0 * * 0'
282-
- command: 'poll_usgs_eq'
282+
- command: 'poll_usgs_earthquake'
283283
schedule: '0 0 * * 0'
284284
# - command: 'notify_validators'
285285
# schedule: '0 0 * * *'

main/sentry.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ class SentryMonitor(models.TextChoices):
128128
INGEST_NS_DOCUMENT = "ingest_ns_document", "0 0 * * 0"
129129
INGEST_NS_INITIATIVES = "ingest_ns_initiatives", "0 0 * * 0"
130130
INGEST_ICRC = "ingest_icrc", "0 3 * * 0"
131-
POLL_USGS_EQ = "poll_usgs_eq", "0 0 * * 0"
132-
POLL_GDACS_FL = "poll_gdacs_fl", "0 0 * * 0"
133-
POLL_GDACS_CY = "poll_gdacs_cy", "0 0 * * 0"
131+
POLL_USGS_EARTHQUAKE = "poll_usgs_earthquake", "0 0 * * 0"
132+
POLL_GDACS_FLOOD = "poll_gdacs_flood", "0 0 * * 0"
133+
POLL_GDACS_CYCLONE = "poll_gdacs_cyclonef", "0 0 * * 0"
134134
# NOTIFY_VALIDATORS = "notify_validators", "0 0 * * *" # NOTE: Disable local unit email notification for now
135135
OAUTH_CLEARTOKENS = "oauth_cleartokens", "0 1 * * *"
136136

0 commit comments

Comments
 (0)