Skip to content

Commit 6d73cdb

Browse files
authored
Merge pull request #2737 from IFRCGo/feat/update-etl-pipeline
chore(etl): update the models to include the event_id.
2 parents 60157c8 + 6771f60 commit 6d73cdb

16 files changed

Lines changed: 378 additions & 258 deletions

alert_system/admin.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,10 @@ class EventAdmin(admin.ModelAdmin):
1515
"stac_id",
1616
"created_at",
1717
"collection",
18-
"guid",
1918
)
2019
list_filter = ("connector", "collection")
2120
readonly_fields = ("connector",)
22-
search_fields = (
23-
"stac_id",
24-
"correlation_id",
25-
)
21+
search_fields = ("stac_id",)
2622

2723

2824
@admin.register(LoadItem)
@@ -31,7 +27,7 @@ class LoadItemAdmin(admin.ModelAdmin):
3127
"id",
3228
"event_title",
3329
"created_at",
34-
"guid",
30+
"event_id",
3531
"item_eligible",
3632
"is_past_event",
3733
)
@@ -46,21 +42,18 @@ class LoadItemAdmin(admin.ModelAdmin):
4642
"related_montandon_events",
4743
"related_go_events",
4844
)
49-
search_fields = (
50-
"id",
51-
"correlation_id",
52-
)
45+
search_fields = ("id",)
5346

5447

5548
@admin.register(AlertEmailThread)
5649
class AlertEmailThreadAdmin(admin.ModelAdmin):
5750
list_display = (
5851
"user",
59-
"parent_guid",
52+
"parent_event_id",
6053
"root_email_message_id",
6154
)
6255
search_fields = (
63-
"parent_guid",
56+
"parent_event_id",
6457
"root_email_message_id",
6558
"user__username",
6659
)

alert_system/email_processing.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,15 @@ def send_alert_email_notification(
6666
if not is_reply:
6767
thread = AlertEmailThread.objects.create(
6868
user=user,
69-
parent_guid=load_item.parent_guid,
69+
parent_event_id=load_item.parent_event_id,
7070
root_email_message_id=message_id,
7171
root_message_sent_at=timezone.now(),
7272
)
7373
email_log.thread = thread
7474
email_log.save(update_fields=["thread"])
7575
logger.info(
76-
f"Alert Email thread created for user [{user.get_full_name()}] " f"with parent_guid [{load_item.parent_guid}]"
76+
f"Alert Email thread created for user [{user.get_full_name()}] "
77+
f"with parent event [{load_item.parent_event_id}]"
7778
)
7879

7980
logger.info(f"Alert email sent to [{user.get_full_name()}] for LoadItem ID [{load_item.id}]")
@@ -127,7 +128,7 @@ def process_email_alert(load_item_id: int) -> None:
127128
existing_threads = {
128129
thread.user_id: thread
129130
for thread in AlertEmailThread.objects.filter(
130-
parent_guid=load_item.parent_guid,
131+
parent_event_id=load_item.parent_event_id,
131132
user_id__in=user_ids,
132133
)
133134
}

0 commit comments

Comments
 (0)