Spaces:
Sleeping
Sleeping
Fix World Bank fetch crash: type mismatch on year comparison
Browse files
main.py
CHANGED
|
@@ -528,7 +528,8 @@ def fetch_worldbank(
|
|
| 528 |
records[country] = {"country": country}
|
| 529 |
# Keep the latest year for each indicator
|
| 530 |
current = records[country].get(ind_id)
|
| 531 |
-
|
|
|
|
| 532 |
records[country][ind_id] = round(float(value), 3)
|
| 533 |
records[country]["_year_" + ind_id] = year
|
| 534 |
time.sleep(0.15) # Rate limit
|
|
|
|
| 528 |
records[country] = {"country": country}
|
| 529 |
# Keep the latest year for each indicator
|
| 530 |
current = records[country].get(ind_id)
|
| 531 |
+
current_year = records[country].get("_year_" + ind_id, "0")
|
| 532 |
+
if current is None or (year and year > current_year):
|
| 533 |
records[country][ind_id] = round(float(value), 3)
|
| 534 |
records[country]["_year_" + ind_id] = year
|
| 535 |
time.sleep(0.15) # Rate limit
|