Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 30 additions & 6 deletions databank/management/commands/sources/RELIEFWEB.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,30 @@ def parse_date(date):
return datetime.datetime.strptime(date.split("T")[0], RELIEFWEB_DATETIME_FORMAT)


def _post_reliefweb(query_params, url, context):
try:
response = requests.post(url, data=query_params)
response.raise_for_status()
return response.json()
except requests.HTTPError as exc:
status_code = exc.response.status_code if exc.response else None
if status_code == 410:
logger.warning(
"ReliefWeb API returned 410 Gone for %s. Skipping %s prefetch. URL: %s",
DISASTER_API,
context,
url,
)
return None
raise
except requests.RequestException:
logger.exception("ReliefWeb API request failed for %s. URL: %s", context, url)
raise
except ValueError:
logger.exception("ReliefWeb API returned invalid JSON for %s. URL: %s", context, url)
raise


def _crises_event_prefetch():
query_params = json.dumps(
{
Expand All @@ -42,9 +66,9 @@ def _crises_event_prefetch():
url = DISASTER_API
data = {}
while True:
response = requests.post(url, data=query_params)
response.raise_for_status()
response = response.json()
response = _post_reliefweb(query_params, url, "crises_event")
if response is None:
return {}

for disaster in response["data"]:
disaster = disaster["fields"]
Expand Down Expand Up @@ -90,9 +114,9 @@ def _epidemics_prefetch():
url = DISASTER_API
data = {}
while True:
response = requests.post(url, data=query_params)
response.raise_for_status()
response = response.json()
response = _post_reliefweb(query_params, url, "epidemics")
if response is None:
return {}

for epidemic in response["data"]:
epidemic = epidemic["fields"]
Expand Down
1 change: 1 addition & 0 deletions deploy/helm/ifrcgo-helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -315,3 +315,4 @@ sshBastion:
thenav56.pub: ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIN/f/A3qkaTHSdbKn8Hv75YiJvRMEXvWTDdIiR7tyAjJ navin@nav-machine
david.pub: ssh-rsa AAAAB3NzaC1yc2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