Skip to content

Commit

Permalink
Add new WFP ADAM domain
Browse files Browse the repository at this point in the history
  • Loading branch information
thenav56 committed Aug 9, 2024
1 parent 0cef9ee commit a670202
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
3 changes: 2 additions & 1 deletion imminent/management/commands/create_adam_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import pytz
import urllib3
from django.conf import settings
from django.core.management.base import BaseCommand

from common.models import Country, HazardType
Expand Down Expand Up @@ -37,7 +38,7 @@ def parse_datetime(self, date):

def handle(self, *args, **options):
http = urllib3.PoolManager()
url = "https://x8qclqysv7.execute-api.eu-west-1.amazonaws.com/dev/events/feed"
url = f"{settings.WFP_ADAM}/events/feed"
response = http.request("GET", url)
data = response.data
values = json.loads(data)
Expand Down
7 changes: 4 additions & 3 deletions imminent/management/commands/create_adam_exposure.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import pytz
import urllib3
from django.conf import settings
from django.core.management.base import BaseCommand
from sentry_sdk.crons import monitor

Expand Down Expand Up @@ -35,7 +36,7 @@ def is_response_valid(response, response_data) -> bool:
return True

def process_earthquakes(self, http):
earthquake_url = "https://x8qclqysv7.execute-api.eu-west-1.amazonaws.com/dev/events/earthquakes/"
earthquake_url = f"{settings.WFP_ADAM}/events/earthquakes/"
response = http.request("GET", earthquake_url)
response_data = json.loads(response.data)

Expand Down Expand Up @@ -77,7 +78,7 @@ def process_earthquakes(self, http):
Adam.objects.get_or_create(**data)

def process_floods(self, http):
flood_url = "https://x8qclqysv7.execute-api.eu-west-1.amazonaws.com/dev/events/floods/"
flood_url = f"{settings.WFP_ADAM}/events/floods/"
response = http.request("GET", flood_url)
response_data = json.loads(response.data)

Expand Down Expand Up @@ -111,7 +112,7 @@ def process_floods(self, http):
Adam.objects.get_or_create(**data)

def process_cyclones(self, http):
cyclone_url = "https://x8qclqysv7.execute-api.eu-west-1.amazonaws.com/dev/events/cyclones/"
cyclone_url = f"{settings.WFP_ADAM}/events/cyclones/"
response = http.request("GET", cyclone_url)
response_data = json.loads(response.data)

Expand Down
3 changes: 2 additions & 1 deletion imminent/management/commands/update_adam_cyclone.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import pytz
import urllib3
from django.conf import settings
from django.core.management.base import BaseCommand
from django.db import models
from django.utils import timezone
Expand Down Expand Up @@ -41,7 +42,7 @@ def handle(self, **options):
logger.info(f"Events to check: {cyclone_events_qs.count()}")
for event_id in cyclone_events_qs:
logger.info(f"Fetching event_id: {event_id}")
cyclone_url = f"https://x8qclqysv7.execute-api.eu-west-1.amazonaws.com/dev/events/cyclones/{event_id}"
cyclone_url = f"{settings.WFP_ADAM}/events/cyclones/{event_id}"
response = http.request("GET", cyclone_url)
data = response.data
cyclone_data = json.loads(data)
Expand Down
3 changes: 3 additions & 0 deletions risk_module/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,3 +416,6 @@ def log_render_extra_context(record):
METEO_SWISS_S3_BUCKET = env("METEOSWISS_S3_BUCKET")
METEO_SWISS_S3_ACCESS_KEY = env("METEOSWISS_S3_ACCESS_KEY")
METEO_SWISS_S3_SECRET_KEY = env("METEOSWISS_S3_SECRET_KEY")

# Static configs
WFP_ADAM = "https://exie6ocssxnczub3aslzanna540gfdjs.lambda-url.eu-west-1.on.aws"

0 comments on commit a670202

Please sign in to comment.