Skip to content

Commit

Permalink
Merge pull request #70 from OCHA-DAP/HAPI-304
Browse files Browse the repository at this point in the history
Redo org table reference periods
  • Loading branch information
b-j-mills authored Jan 23, 2024
2 parents f3b629d + 047e1e7 commit 8b594a9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 26 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [0.6.8] - 2024-01-23

### Changed

- Change date in org table to match v1 release date
- Correct outdated admin logic in operational presence

## [0.6.7] - 2024-01-17

### Added
Expand Down
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ colorama==0.4.6
# via typer
coverage[toml]==7.4.0
# via pytest-cov
cryptography==41.0.7
cryptography==42.0.0
# via pyopenssl
defopt==6.4.0
# via hdx-python-api
distlib==0.3.8
# via virtualenv
dnspython==2.4.2
dnspython==2.5.0
# via email-validator
docopt==0.6.2
# via
Expand Down Expand Up @@ -119,7 +119,7 @@ markdown-it-py==3.0.0
# via rich
marko==2.0.2
# via frictionless
markupsafe==2.1.3
markupsafe==2.1.4
# via jinja2
mdurl==0.1.2
# via markdown-it-py
Expand Down Expand Up @@ -171,7 +171,7 @@ pydantic-core==2.14.6
# via pydantic
pygments==2.17.2
# via rich
pyopenssl==23.3.0
pyopenssl==24.0.0
# via
# hdx-python-api
# ndg-httpsclient
Expand Down
29 changes: 8 additions & 21 deletions src/hapi/pipelines/database/operational_presence.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from hapi_schema.db_operational_presence import DBOperationalPresence
from hdx.location.names import clean_name
from hdx.utilities.dateparse import parse_date
from sqlalchemy.orm import Session

from . import admins
Expand Down Expand Up @@ -57,6 +58,9 @@ def populate(self):

for admin_code, org_names in values[org_name_index].items():
for i, org_name in enumerate(org_names):
admin2_code = admins.get_admin2_code_based_on_level(
admin_code=admin_code, admin_level=admin_level
)
# TODO: find the country code for get_org_info parameter "location"
org_info = self._org.get_org_info(
org_name, location="Country code"
Expand Down Expand Up @@ -95,37 +99,20 @@ def populate(self):
)
not in self._org.data
):
# Date is release date of HAPI v1
self._org.populate_single(
acronym=org_acronym,
org_name=org_name,
org_type=org_type_code,
reference_period_start=reference_period_start,
reference_period_end=reference_period_end,
reference_period_start=parse_date(
"2023-11-21"
),
)
sector = values[sector_index][admin_code][i]
sector_code = self._sector.get_sector_code(sector)
if not sector_code:
logger.error(f"Sector {sector} not in table")

if admin_level == "national":
admin1_code = (
admins.get_admin1_to_location_connector_code(
admin_code
)
)
admin2_code = (
admins.get_admin2_to_admin1_connector_code(
admin1_code
)
)
if admin_level == "adminone":
admin2_code = (
admins.get_admin2_to_admin1_connector_code(
admin1_code=admin_code
)
)
elif admin_level == "admintwo":
admin2_code = admin_code
resource_ref = self._metadata.resource_data[
resource_id
]
Expand Down
2 changes: 1 addition & 1 deletion src/hapi/pipelines/database/org.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def populate_single(
org_name,
org_type,
reference_period_start,
reference_period_end,
reference_period_end=None,
):
logger.info(f"Adding org {org_name}")
org_row = DBOrg(
Expand Down

0 comments on commit 8b594a9

Please sign in to comment.