Skip to content

Conversation

@sandeshit
Copy link
Contributor

Changes

  • Alert-system app
  • Polling, ETL

Checklist

Things that should succeed before merging.

  • Updated/ran unit tests
  • Updated CHANGELOG.md

Release

If there is a version update, make sure to tag the repository with the latest version.

@sandeshit sandeshit mentioned this pull request Nov 28, 2025
2 tasks
@sandeshit sandeshit changed the base branch from project/alert-system-workflow to develop December 7, 2025 18:22
@sandeshit sandeshit changed the base branch from develop to project/alert-system-workflow December 7, 2025 18:23
@sandeshit sandeshit marked this pull request as draft December 7, 2025 18:24
@sandeshit sandeshit requested a review from susilnem December 8, 2025 09:09
Copy link
Member

@susilnem susilnem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor changes...

Copy link
Member

@susilnem susilnem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small changes!

Copy link
Contributor

@sudip-khanal sudip-khanal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor changes

@sandeshit sandeshit requested a review from susilnem December 12, 2025 09:02
Copy link
Member

@susilnem susilnem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have any analytics on usage and memory consumption?
Has any profiling been done so far?

Comment on lines 120 to 124
go_event_ids = list(
Event.objects.filter(field_reports__num_affected__gte=item.total_people_exposed, dtype=connector.dtype)
.values_list("id", flat=True)
.distinct()
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

N+1

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

N+M+1

.distinct()
)

item.related_go_events = go_event_ids
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check if we have instead use M2M

Use bulk insert to add M2M (Use ignore existing)

)

action = "Created" if created else "Updated"
logger.info(f"{action} Event for correlation_id={correlation_id}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger.info(f"{action} Event for correlation_id={correlation_id}")
logger.info(f"{action} Event for {correlation_id=}")

Comment on lines 13 to 18
event_collection_type = gdacs_flood_config.event_collection_type
hazard_collection_type = getattr(gdacs_flood_config, "hazard_collection_type", None)
impact_collection_type = getattr(gdacs_flood_config, "impact_collection_type", None)
filter_event = getattr(gdacs_flood_config, "filter_event", None)
transformer_class = GdacsTransformer
loader_class = GdacsLoader
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can replace all this with a single typed dict...

Comment on lines 286 to 287
def _hazard_filter(self, unit: str, value: int) -> str:
return f"monty:hazard_detail.severity_unit = '{unit}' AND " f"monty:hazard_detail.severity_value >= {value}"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sandeshit To verify: unit and value mayn't exist in all the source items. Handle it if it is None or NaN.

current_payload = filters.copy() if filters else None

while current_url:
response = httpx.get(current_url, params=current_payload, timeout=30)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sandeshit instead of hard code timeout value, would be nice to pass it in the arg with default val of 30.

"event_collection_type": "gdacs-events",
"hazard_collection_type": "gdacs-hazards",
"impact_collection_type": "gdacs-impacts",
"filter_event": {"hazard_codes": ["FL", "MH0600", "nat-hyd-flo-flo"]},

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sandeshit can we handle multiple set of same/similar hazards? Example: FL is a general one for Flood but there are other types of Flood as well like Flash Flood etc. What if we want to handle different sets of similar hazard types. Might need to discuss.

# NOTE: This logic might change in future
def compute_people_exposed(self, metadata_list) -> int:
for data in metadata_list:
if data["category"] == "people" and data["type"] == "affected_total":

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sandeshit instead of hard coding the types, can we make use of Enums ?

return {
"severity_unit": "",
"severity_label": "",
"severity_value": 0,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sandeshit The severity_value: 0 carries a meaning. If the hazard_item is not present, can we use None or do it differently.

return {
"severity_unit": detail.get("severity_unit", ""),
"severity_label": detail.get("severity_label", ""),
"severity_value": detail.get("severity_value", 0),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sandeshit The severity_value: 0 carries a meaning. If the hazard_item is not present, can we use None or do it differently.

return {
"severity_unit": "",
"severity_label": "",
"severity_value": 0,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sandeshit check the comment above

- Added category and type enum.
- Alter people and building exposed fallback to None.
- Add polling start date and lookback weeks field in Connector.
- Squash Migrations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants