Skip to content

DEP: Add emergency api endpoint#2723

Draft
sudip-khanal wants to merge 4 commits intoproject/dref-emergency-pagesfrom
feat/add-emergency-api-endpoint
Draft

DEP: Add emergency api endpoint#2723
sudip-khanal wants to merge 4 commits intoproject/dref-emergency-pagesfrom
feat/add-emergency-api-endpoint

Conversation

@sudip-khanal
Copy link
Copy Markdown
Contributor

Changes

  • Add source Enum field in place of auto generated source field on event model.
  • Migrate existing event records to enum type.
  • Update related serializer and tests.
  • Add new emergency api endpoint.
  • Attach latest field report to emergency api endpoint.

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.

@sudip-khanal sudip-khanal requested a review from susilnem April 24, 2026 10:36
Comment thread api/models.py Outdated
Comment thread api/models.py Outdated
Comment thread api/serializers.py Outdated
Comment thread api/drf_views.py Outdated
Comment thread api/drf_views.py Outdated
Comment thread api/drf_views.py
Comment thread api/drf_views.py
Comment thread api/models.py Outdated
Comment thread api/models.py Outdated
Comment thread api/serializers.py
- Add Enum for event sources.
- Add source field in place of auto generated source field on event model.
- Migrate existing event records to enum type.
- Update related serializers and tests.
- Add new emergency api for.
- Attach latest field report.
- Add test case for emergency endpoint.
@sudip-khanal sudip-khanal force-pushed the feat/add-emergency-api-endpoint branch from fd14a97 to efb86d8 Compare May 4, 2026 08:21

def handle(self, *args, **options):
guids = [e.auto_generated_source for e in Event.objects.filter(auto_generated_source__startswith="www.who.int")]
guids = [e.source for e in Event.objects.filter(source=Event.EventSource.WHO)]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you confirm this? It looks like GUIDs are being used for mapping, but they might not match when scraping from the source.

if data["guid"] in guids:

Comment on lines +25 to +26
Event.objects.bulk_update(to_update, ["source", "auto_generated"])
self.stdout.write(self.style.SUCCESS("Event sources have been updated successfully."))
Copy link
Copy Markdown
Member

@susilnem susilnem May 4, 2026

Choose a reason for hiding this comment

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

Suggested change
Event.objects.bulk_update(to_update, ["source", "auto_generated"])
self.stdout.write(self.style.SUCCESS("Event sources have been updated successfully."))
updated_events = Event.objects.bulk_update(to_update, ["source", "auto_generated"])
self.stdout.write(self.style.SUCCESS(f"Total {updated_events} Events sources have been updated successfully."))

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.

2 participants