Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GNI Per Capita for WB #2135

Merged
merged 2 commits into from
May 13, 2024
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
8 changes: 5 additions & 3 deletions api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from django.contrib.auth.models import User
from django.conf import settings
from django.db import transaction
from django.db import models
from django.contrib.auth.models import Permission
from django.utils.translation import get_language as django_get_language

Expand Down Expand Up @@ -775,18 +776,19 @@ def get_centroid(country) -> dict:
return country.centroid and json.loads(country.centroid.geojson)

@extend_schema_field(
MiniDelegationOfficeSerializer
MiniDelegationOfficeSerializer(many=True)
)
def get_country_delegation(self, country):
return DelegationOffice.objects.filter(
dotype__name="Country Delegation",
country=country,
).values(
'hod_first_name',
'hod_last_name',
'hod_mobile_number',
'hod_email',
).first()
).annotate(
dotype_name=models.F('dotype__name')
).distinct()


class CountryKeyDocumentSerializer(ModelSerializer):
Expand Down
7 changes: 5 additions & 2 deletions databank/management/commands/ingest_worldbank.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ def handle(self, *args, **kwargs):
('IQ.CPA.GNDR.XQ', CO.world_bank_gender_inequality_index),
('SP.DYN.LE00.IN', CO.world_bank_life_expectancy),
('SE.ADT.LITR.ZS', CO.world_bank_literacy_rate),
('SI.POV.NAHC', CO.world_bank_poverty_rate)
('SI.POV.NAHC', CO.world_bank_poverty_rate),
('NY.GNP.PCAP.CD', CO.world_bank_gni_capita)
)

world_bank_indicators = [indicator for indicator, _ in world_bank_indicator_map]
Expand Down Expand Up @@ -95,6 +96,7 @@ def handle(self, *args, **kwargs):
overview.world_bank_life_expectancy = indicators[7][0]
overview.world_bank_literacy_rate = indicators[8][0]
overview.world_bank_poverty_rate = indicators[9][0]
overview.world_bank_gni_capita = indicators[10][0]
overview.save(
update_fields=[
'world_bank_population',
Expand All @@ -106,6 +108,7 @@ def handle(self, *args, **kwargs):
'world_bank_gender_inequality_index',
'world_bank_life_expectancy',
'world_bank_literacy_rate',
'world_bank_poverty_rate'
'world_bank_poverty_rate',
'world_bank_gni_capita',
]
)
18 changes: 18 additions & 0 deletions databank/migrations/0025_countryoverview_world_bank_gni_capita.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.25 on 2024-05-08 05:39

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('databank', '0024_countryoverview_fdrs_data_fetched_year'),
]

operations = [
migrations.AddField(
model_name='countryoverview',
name='world_bank_gni_capita',
field=models.IntegerField(blank=True, null=True, verbose_name='world bank GNI Per Capita'),
),
]
4 changes: 4 additions & 0 deletions databank/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,10 @@ class CountryOverview(models.Model):
verbose_name=_('world bank poverty rate'),
null=True, blank=True
)
world_bank_gni_capita = models.IntegerField(
verbose_name=_('world bank GNI Per Capita'),
null=True, blank=True
)

# fetched from unicef
unicef_population_under_18 = models.IntegerField(
Expand Down
3 changes: 3 additions & 0 deletions local_units/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,14 @@ class LocalUnitOptionsSerializer(serializers.Serializer):


class MiniDelegationOfficeSerializer(serializers.ModelSerializer):
dotype_name = serializers.CharField(source='dotype.name', read_only=True)

class Meta:
model = DelegationOffice
fields = (
'hod_first_name',
'hod_last_name',
'hod_mobile_number',
'hod_email',
'dotype_name'
)