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.

"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.

@sandeshit sandeshit force-pushed the project/alert-system-workflow branch from d71e1d0 to 7dc5624 Compare January 19, 2026 06:27
- 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.
class Meta:
verbose_name = _("Connector")
verbose_name_plural = _("Connectors")
ordering = ["type"]
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
ordering = ["type"]
ordering = ["id","type"]

connector.save(update_fields=["status", "last_success_run"] if status == Connector.Status.SUCCESS else ["status"])


def get_connector_processor(connector_id: int):
Copy link
Member

Choose a reason for hiding this comment

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

Move this section to model.py

from alert_system.models import Connector


def set_connector_status(connector, status):
Copy link
Member

Choose a reason for hiding this comment

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

This one too

processor, connector = get_connector_processor(connector_id)

try:
set_connector_status(connector, Connector.Status.RUNNING)
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
set_connector_status(connector, Connector.Status.RUNNING)
connector.set_connector_status(Connector.Status.RUNNING)

SOURCE_TYPE = Connector.ConnectorType.GDACS_CYCLONE

def handle(self, *args, **options):
self.stdout.write("Starting extraction task...")
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
self.stdout.write("Starting extraction task...")
self.stdout.write("Starting extraction task for SOURCE_TYPE.label ...")

- Remove mappings.py.
- Move connector registry inside connector model.
- Rename variables in tasks.py.
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