Skip to content

Commit 6efc352

Browse files
committed
Skip FTS_HPC processing when no data
1 parent 3baff74 commit 6efc352

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

77
## Unreleased
8+
- Skip FTS_HPC processing when no data
89
- Fix TypeError of /api/v1/search/
910
- Update Molnix alert status even when no event
1011
- NSIA, ESF, CBF changes in ingest_ns_initiatives

databank/management/commands/sources/FTS_HPC.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,25 @@ def prefetch():
2727

2828
g_sheet_data = list(csv.DictReader(io.StringIO(g_sheet_data.text)))
2929

30-
gho_data = {
31-
f"{d['Country #country+code'].upper()}-{d['Year #date+year']}": {
32-
"people_in_need": d["PIN #inneed"],
33-
"people_targeted": d["PT #targeted"],
34-
"funding_total_usd": d["Funding #value+required+total+usd"],
35-
"funding_required_usd": d["Requirements #value+funding+required+usd"],
36-
}
37-
for d in g_sheet_data
38-
}
30+
gho_data = {}
31+
for d in g_sheet_data:
32+
if (
33+
"Country #country+code" in d
34+
and "Year #date+year" in d
35+
and "PIN #inneed" in d
36+
and "PT #targeted" in d
37+
and "Funding #value+required+total+usd" in d
38+
and "Requirements #value+funding+required+usd" in d
39+
):
40+
key = f"{d['Country #country+code'].upper()}-{d['Year #date+year']}"
41+
gho_data[key] = {
42+
"people_in_need": d["PIN #inneed"],
43+
"people_targeted": d["PT #targeted"],
44+
"funding_total_usd": d["Funding #value+required+total+usd"],
45+
"funding_required_usd": d["Requirements #value+funding+required+usd"],
46+
}
47+
else:
48+
print(f"Warning: Skipping FTS_HPC data due to missing keys: {d}")
3949

4050
return gho_data, len(gho_data), GOOGLE_SHEET_URL
4151

0 commit comments

Comments
 (0)