hapi-schema 0.9.6__tar.gz → 0.9.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/.config/pre-commit-config.yaml +2 -2
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/PKG-INFO +4 -3
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/changelog.md +8 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/pyproject.toml +2 -2
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/requirements.txt +10 -10
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/src/hapi_schema/_version.py +2 -2
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/src/hapi_schema/db_conflict_event.py +3 -2
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/src/hapi_schema/db_food_price.py +3 -2
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/src/hapi_schema/db_food_security.py +3 -2
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/src/hapi_schema/db_funding.py +3 -2
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/src/hapi_schema/db_humanitarian_needs.py +5 -2
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/src/hapi_schema/db_idps.py +3 -2
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/src/hapi_schema/db_national_risk.py +3 -2
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/src/hapi_schema/db_operational_presence.py +5 -2
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/src/hapi_schema/db_population.py +3 -2
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/src/hapi_schema/db_poverty_rate.py +3 -2
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/src/hapi_schema/db_refugees.py +5 -3
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/src/hapi_schema/db_returnees.py +5 -3
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/src/hapi_schema/db_views_as_tables.py +1 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/src/hapi_schema/db_wfp_market.py +2 -0
- hapi_schema-0.9.7/src/hapi_schema/utils/endpoint_constants.py +35 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/test_conflict_event.py +1 -1
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/test_food_price.py +2 -2
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/test_food_security.py +1 -1
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/test_population.py +2 -2
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/test_poverty_rate.py +1 -1
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/test_refugees.py +2 -3
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/test_returnees.py +1 -2
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/test_views_as_tables.py +1 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/.config/coveragerc +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/.config/pytest.ini +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/.config/ruff.toml +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/.github/workflows/publish.yaml +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/.github/workflows/run-python-tests.yaml +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/.gitignore +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/LICENSE +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/README.md +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/contributing.md +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/docker/docker-compose.yml +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/initialize_test_db.sh +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/src/hapi_schema/__init__.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/src/hapi_schema/db_admin1.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/src/hapi_schema/db_admin2.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/src/hapi_schema/db_currency.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/src/hapi_schema/db_dataset.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/src/hapi_schema/db_location.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/src/hapi_schema/db_org.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/src/hapi_schema/db_org_type.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/src/hapi_schema/db_patch.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/src/hapi_schema/db_resource.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/src/hapi_schema/db_sector.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/src/hapi_schema/db_wfp_commodity.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/src/hapi_schema/utils/__init__.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/src/hapi_schema/utils/base.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/src/hapi_schema/utils/constraints.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/src/hapi_schema/utils/enums.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/src/hapi_schema/utils/hapi_views_code_generator.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/src/hapi_schema/utils/view_as_table_code_generator.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/src/hapi_schema/utils/view_as_table_definitions.toml +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/src/hapi_schema/utils/view_params.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/src/hapi_schema/views.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/conftest.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/sample_data/__init__.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/sample_data/data_admin1.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/sample_data/data_admin2.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/sample_data/data_conflict_event.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/sample_data/data_currency.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/sample_data/data_dataset.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/sample_data/data_food_price.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/sample_data/data_food_security.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/sample_data/data_funding.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/sample_data/data_humanitarian_needs.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/sample_data/data_idps.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/sample_data/data_location.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/sample_data/data_national_risk.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/sample_data/data_operational_presence.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/sample_data/data_org.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/sample_data/data_org_type.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/sample_data/data_patch.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/sample_data/data_population.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/sample_data/data_poverty_rate.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/sample_data/data_refugees.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/sample_data/data_resource.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/sample_data/data_returnees.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/sample_data/data_sector.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/sample_data/data_wfp_commodity.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/sample_data/data_wfp_market.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/test_admin1.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/test_admin2.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/test_currency.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/test_dataset.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/test_funding.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/test_humanitarian_needs.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/test_idps.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/test_location.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/test_national_risk.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/test_operational_presence.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/test_org.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/test_org_type.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/test_patch.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/test_resource.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/test_sector.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/test_wfp_commodity.py +0 -0
- {hapi_schema-0.9.6 → hapi_schema-0.9.7}/tests/test_wfp_market.py +0 -0
|
@@ -8,7 +8,7 @@ repos:
|
|
|
8
8
|
- id: end-of-file-fixer
|
|
9
9
|
- id: check-ast
|
|
10
10
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
11
|
-
rev: v0.
|
|
11
|
+
rev: v0.9.4
|
|
12
12
|
hooks:
|
|
13
13
|
# Run the linter.
|
|
14
14
|
- id: ruff
|
|
@@ -17,7 +17,7 @@ repos:
|
|
|
17
17
|
- id: ruff-format
|
|
18
18
|
args: [--config, .config/ruff.toml]
|
|
19
19
|
- repo: https://github.com/astral-sh/uv-pre-commit
|
|
20
|
-
rev: 0.
|
|
20
|
+
rev: 0.5.28
|
|
21
21
|
hooks:
|
|
22
22
|
# Run the pip compile
|
|
23
23
|
- id: pip-compile
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: hapi-schema
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.7
|
|
4
4
|
Summary: HAPI database schema specified in SQLAlchemy
|
|
5
5
|
Project-URL: Homepage, https://github.com/OCHA-DAP/hapi-schemas
|
|
6
6
|
Author-email: Simon Johnson <simon.johnson@un.org>
|
|
7
7
|
License: MIT
|
|
8
|
+
License-File: LICENSE
|
|
8
9
|
Keywords: HDX,hapi,schema
|
|
9
10
|
Classifier: Intended Audience :: Developers
|
|
10
11
|
Classifier: License :: OSI Approved :: MIT License
|
|
@@ -25,7 +26,7 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
|
25
26
|
Requires-Python: >=3.8
|
|
26
27
|
Requires-Dist: sqlalchemy
|
|
27
28
|
Provides-Extra: database
|
|
28
|
-
Requires-Dist: hdx-python-database>=1.3.
|
|
29
|
+
Requires-Dist: hdx-python-database>=1.3.5; extra == 'database'
|
|
29
30
|
Provides-Extra: dev
|
|
30
31
|
Requires-Dist: pre-commit; extra == 'dev'
|
|
31
32
|
Provides-Extra: test
|
|
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## 0.9.7
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- Changed endpoint names for conflict event, food price, food security, population, poverty rate, and refugees tables
|
|
13
|
+
- Include origin and asylum in data availability for refugees and returnees
|
|
14
|
+
- Added admin level to WFP Market table
|
|
15
|
+
|
|
8
16
|
## 0.9.6
|
|
9
17
|
|
|
10
18
|
### Fixed
|
|
@@ -42,7 +42,7 @@ content-type = "text/markdown"
|
|
|
42
42
|
Homepage = "https://github.com/OCHA-DAP/hapi-schemas"
|
|
43
43
|
|
|
44
44
|
[project.optional-dependencies]
|
|
45
|
-
database = ["hdx-python-database>=1.3.
|
|
45
|
+
database = ["hdx-python-database>=1.3.5"]
|
|
46
46
|
dev = ["pre-commit"]
|
|
47
47
|
test = ["hdx-python-database>=1.3.4", "psycopg[binary]", "pytest", "pytest-cov"]
|
|
48
48
|
|
|
@@ -86,7 +86,7 @@ run = """
|
|
|
86
86
|
"""
|
|
87
87
|
|
|
88
88
|
[tool.hatch.envs.hatch-static-analysis]
|
|
89
|
-
dependencies = ["ruff==0.
|
|
89
|
+
dependencies = ["ruff==0.9.4"]
|
|
90
90
|
|
|
91
91
|
[tool.hatch.envs.hatch-static-analysis.scripts]
|
|
92
92
|
format-check = ["ruff format --config .config/ruff.toml --check --diff {args:.}",]
|
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
# uv pip compile pyproject.toml --resolver=backtracking --all-extras -o requirements.txt
|
|
3
3
|
cfgv==3.4.0
|
|
4
4
|
# via pre-commit
|
|
5
|
-
coverage==7.6.
|
|
5
|
+
coverage==7.6.11
|
|
6
6
|
# via pytest-cov
|
|
7
7
|
distlib==0.3.9
|
|
8
8
|
# via virtualenv
|
|
9
|
-
filelock==3.
|
|
9
|
+
filelock==3.17.0
|
|
10
10
|
# via virtualenv
|
|
11
11
|
greenlet==3.1.1
|
|
12
12
|
# via sqlalchemy
|
|
13
|
-
hdx-python-database==1.3.
|
|
13
|
+
hdx-python-database==1.3.5
|
|
14
14
|
# via hapi-schema (pyproject.toml)
|
|
15
|
-
identify==2.6.
|
|
15
|
+
identify==2.6.7
|
|
16
16
|
# via pre-commit
|
|
17
17
|
iniconfig==2.0.0
|
|
18
18
|
# via pytest
|
|
@@ -24,13 +24,13 @@ platformdirs==4.3.6
|
|
|
24
24
|
# via virtualenv
|
|
25
25
|
pluggy==1.5.0
|
|
26
26
|
# via pytest
|
|
27
|
-
pre-commit==4.0
|
|
27
|
+
pre-commit==4.1.0
|
|
28
28
|
# via hapi-schema (pyproject.toml)
|
|
29
|
-
psycopg==3.2.
|
|
29
|
+
psycopg==3.2.4
|
|
30
30
|
# via hapi-schema (pyproject.toml)
|
|
31
|
-
psycopg-binary==3.2.
|
|
31
|
+
psycopg-binary==3.2.4
|
|
32
32
|
# via psycopg
|
|
33
|
-
pytest==8.3.
|
|
33
|
+
pytest==8.3.4
|
|
34
34
|
# via
|
|
35
35
|
# hapi-schema (pyproject.toml)
|
|
36
36
|
# pytest-cov
|
|
@@ -38,7 +38,7 @@ pytest-cov==6.0.0
|
|
|
38
38
|
# via hapi-schema (pyproject.toml)
|
|
39
39
|
pyyaml==6.0.2
|
|
40
40
|
# via pre-commit
|
|
41
|
-
sqlalchemy==2.0.
|
|
41
|
+
sqlalchemy==2.0.38
|
|
42
42
|
# via
|
|
43
43
|
# hapi-schema (pyproject.toml)
|
|
44
44
|
# hdx-python-database
|
|
@@ -46,5 +46,5 @@ typing-extensions==4.12.2
|
|
|
46
46
|
# via
|
|
47
47
|
# psycopg
|
|
48
48
|
# sqlalchemy
|
|
49
|
-
virtualenv==20.
|
|
49
|
+
virtualenv==20.29.2
|
|
50
50
|
# via pre-commit
|
|
@@ -14,6 +14,7 @@ from sqlalchemy.sql.expression import literal
|
|
|
14
14
|
from hapi_schema.db_admin1 import DBAdmin1, DBLocation
|
|
15
15
|
from hapi_schema.db_admin2 import DBAdmin2
|
|
16
16
|
from hapi_schema.db_resource import DBResource
|
|
17
|
+
from hapi_schema.utils import endpoint_constants
|
|
17
18
|
from hapi_schema.utils.base import Base
|
|
18
19
|
from hapi_schema.utils.constraints import (
|
|
19
20
|
population_constraint,
|
|
@@ -102,8 +103,8 @@ view_params_conflict_event = ViewParams(
|
|
|
102
103
|
# Results format: category, subcategory, location_name, location_code, admin1_name, admin1_code, admin2_name, admin2_code, hapi_updated_date
|
|
103
104
|
availability_stmt_conflict_event = (
|
|
104
105
|
select(
|
|
105
|
-
literal(
|
|
106
|
-
literal(
|
|
106
|
+
literal(endpoint_constants.CONFLICT_EVENT_CAT).label("category"),
|
|
107
|
+
literal(endpoint_constants.CONFLICT_EVENT_SUBCAT).label("subcategory"),
|
|
107
108
|
DBLocation.name.label("location_name"),
|
|
108
109
|
DBLocation.code.label("location_code"),
|
|
109
110
|
DBAdmin1.name.label("admin1_name"),
|
|
@@ -16,6 +16,7 @@ from hapi_schema.db_currency import DBCurrency
|
|
|
16
16
|
from hapi_schema.db_resource import DBResource
|
|
17
17
|
from hapi_schema.db_wfp_commodity import DBWFPCommodity
|
|
18
18
|
from hapi_schema.db_wfp_market import DBWFPMarket
|
|
19
|
+
from hapi_schema.utils import endpoint_constants
|
|
19
20
|
from hapi_schema.utils.base import Base
|
|
20
21
|
from hapi_schema.utils.constraints import (
|
|
21
22
|
non_negative_constraint,
|
|
@@ -136,8 +137,8 @@ view_params_food_price = ViewParams(
|
|
|
136
137
|
# Results format: category, subcategory, location_name, location_code, admin1_name, admin1_code, admin2_name, admin2_code, hapi_updated_date
|
|
137
138
|
availability_stmt_food_price = (
|
|
138
139
|
select(
|
|
139
|
-
literal(
|
|
140
|
-
literal(
|
|
140
|
+
literal(endpoint_constants.FOOD_PRICE_CAT).label("category"),
|
|
141
|
+
literal(endpoint_constants.FOOD_PRICE_SUBCAT).label("subcategory"),
|
|
141
142
|
DBLocation.name.label("location_name"),
|
|
142
143
|
DBLocation.code.label("location_code"),
|
|
143
144
|
DBAdmin1.name.label("admin1_name"),
|
|
@@ -17,6 +17,7 @@ from hapi_schema.db_admin1 import DBAdmin1
|
|
|
17
17
|
from hapi_schema.db_admin2 import DBAdmin2
|
|
18
18
|
from hapi_schema.db_location import DBLocation
|
|
19
19
|
from hapi_schema.db_resource import DBResource
|
|
20
|
+
from hapi_schema.utils import endpoint_constants
|
|
20
21
|
from hapi_schema.utils.base import Base
|
|
21
22
|
from hapi_schema.utils.constraints import (
|
|
22
23
|
population_constraint,
|
|
@@ -106,8 +107,8 @@ view_params_food_security = ViewParams(
|
|
|
106
107
|
# Results format: category, subcategory, location_name, location_code, admin1_name, admin1_code, admin2_name, admin2_code, hapi_updated_date
|
|
107
108
|
availability_stmt_food_security = (
|
|
108
109
|
select(
|
|
109
|
-
literal(
|
|
110
|
-
literal(
|
|
110
|
+
literal(endpoint_constants.FOOD_SECURITY_CAT).label("category"),
|
|
111
|
+
literal(endpoint_constants.FOOD_SECURITY_SUBCAT).label("subcategory"),
|
|
111
112
|
DBLocation.name.label("location_name"),
|
|
112
113
|
DBLocation.code.label("location_code"),
|
|
113
114
|
DBAdmin1.name.label("admin1_name"),
|
|
@@ -15,6 +15,7 @@ from sqlalchemy.sql.expression import literal
|
|
|
15
15
|
|
|
16
16
|
from hapi_schema.db_location import DBLocation
|
|
17
17
|
from hapi_schema.db_resource import DBResource
|
|
18
|
+
from hapi_schema.utils import endpoint_constants
|
|
18
19
|
from hapi_schema.utils.base import Base
|
|
19
20
|
from hapi_schema.utils.constraints import reference_period_constraint
|
|
20
21
|
from hapi_schema.utils.view_params import ViewParams
|
|
@@ -99,8 +100,8 @@ view_params_funding = ViewParams(
|
|
|
99
100
|
# Results format: category, subcategory, location_name, location_code, admin1_name, admin1_code, admin2_name, admin2_code, hapi_updated_date
|
|
100
101
|
availability_stmt_funding = (
|
|
101
102
|
select(
|
|
102
|
-
literal(
|
|
103
|
-
literal(
|
|
103
|
+
literal(endpoint_constants.FUNDING_CAT).label("category"),
|
|
104
|
+
literal(endpoint_constants.FUNDING_SUBCAT).label("subcategory"),
|
|
104
105
|
DBLocation.name.label("location_name"),
|
|
105
106
|
DBLocation.code.label("location_code"),
|
|
106
107
|
literal("").label("admin1_name"),
|
|
@@ -16,6 +16,7 @@ from hapi_schema.db_admin2 import DBAdmin2
|
|
|
16
16
|
from hapi_schema.db_location import DBLocation
|
|
17
17
|
from hapi_schema.db_resource import DBResource
|
|
18
18
|
from hapi_schema.db_sector import DBSector
|
|
19
|
+
from hapi_schema.utils import endpoint_constants
|
|
19
20
|
from hapi_schema.utils.base import Base
|
|
20
21
|
from hapi_schema.utils.constraints import (
|
|
21
22
|
population_constraint,
|
|
@@ -116,8 +117,10 @@ view_params_humanitarian_needs = ViewParams(
|
|
|
116
117
|
# Results format: category, subcategory, location_name, location_code, admin1_name, admin1_code, admin2_name, admin2_code, hapi_updated_date
|
|
117
118
|
availability_stmt_humanitarian_needs = (
|
|
118
119
|
select(
|
|
119
|
-
literal(
|
|
120
|
-
literal(
|
|
120
|
+
literal(endpoint_constants.HUMANITARIAN_NEEDS_CAT).label("category"),
|
|
121
|
+
literal(endpoint_constants.HUMANITARIAN_NEEDS_SUBCAT).label(
|
|
122
|
+
"subcategory"
|
|
123
|
+
),
|
|
121
124
|
DBLocation.name.label("location_name"),
|
|
122
125
|
DBLocation.code.label("location_code"),
|
|
123
126
|
DBAdmin1.name.label("admin1_name"),
|
|
@@ -15,6 +15,7 @@ from hapi_schema.db_admin1 import DBAdmin1
|
|
|
15
15
|
from hapi_schema.db_admin2 import DBAdmin2
|
|
16
16
|
from hapi_schema.db_location import DBLocation
|
|
17
17
|
from hapi_schema.db_resource import DBResource
|
|
18
|
+
from hapi_schema.utils import endpoint_constants
|
|
18
19
|
from hapi_schema.utils.base import Base
|
|
19
20
|
from hapi_schema.utils.constraints import (
|
|
20
21
|
greater_than_constraint,
|
|
@@ -106,8 +107,8 @@ view_params_idps = ViewParams(
|
|
|
106
107
|
# Results format: category, subcategory, location_name, location_code, admin1_name, admin1_code, admin2_name, admin2_code, hapi_updated_date
|
|
107
108
|
availability_stmt_idps = (
|
|
108
109
|
select(
|
|
109
|
-
literal(
|
|
110
|
-
literal(
|
|
110
|
+
literal(endpoint_constants.IDPS_CAT).label("category"),
|
|
111
|
+
literal(endpoint_constants.IDPS_SUBCAT).label("subcategory"),
|
|
111
112
|
DBLocation.name.label("location_name"),
|
|
112
113
|
DBLocation.code.label("location_code"),
|
|
113
114
|
DBAdmin1.name.label("admin1_name"),
|
|
@@ -15,6 +15,7 @@ from sqlalchemy.sql.expression import literal
|
|
|
15
15
|
|
|
16
16
|
from hapi_schema.db_location import DBLocation
|
|
17
17
|
from hapi_schema.db_resource import DBResource
|
|
18
|
+
from hapi_schema.utils import endpoint_constants
|
|
18
19
|
from hapi_schema.utils.base import Base
|
|
19
20
|
from hapi_schema.utils.constraints import (
|
|
20
21
|
general_risk_constraint,
|
|
@@ -102,8 +103,8 @@ view_params_national_risk = ViewParams(
|
|
|
102
103
|
# Results format: category, subcategory, location_name, location_code, admin1_name, admin1_code, admin2_name, admin2_code, hapi_updated_date
|
|
103
104
|
availability_stmt_national_risk = (
|
|
104
105
|
select(
|
|
105
|
-
literal(
|
|
106
|
-
literal(
|
|
106
|
+
literal(endpoint_constants.NATIONAL_RISK_CAT).label("category"),
|
|
107
|
+
literal(endpoint_constants.NATIONA_RISK_SUBCAT).label("subcategory"),
|
|
107
108
|
DBLocation.name.label("location_name"),
|
|
108
109
|
DBLocation.code.label("location_code"),
|
|
109
110
|
literal("").label("admin1_name"),
|
|
@@ -18,6 +18,7 @@ from hapi_schema.db_location import DBLocation
|
|
|
18
18
|
from hapi_schema.db_org import DBOrg, DBOrgType
|
|
19
19
|
from hapi_schema.db_resource import DBResource
|
|
20
20
|
from hapi_schema.db_sector import DBSector
|
|
21
|
+
from hapi_schema.utils import endpoint_constants
|
|
21
22
|
from hapi_schema.utils.base import Base
|
|
22
23
|
from hapi_schema.utils.constraints import reference_period_constraint
|
|
23
24
|
from hapi_schema.utils.view_params import ViewParams
|
|
@@ -125,8 +126,10 @@ view_params_operational_presence = ViewParams(
|
|
|
125
126
|
# Results format: category, subcategory, location_name, location_code, admin1_name, admin1_code, admin2_name, admin2_code, hapi_updated_date
|
|
126
127
|
availability_stmt_operational_presence = (
|
|
127
128
|
select(
|
|
128
|
-
literal(
|
|
129
|
-
literal(
|
|
129
|
+
literal(endpoint_constants.OPERATIONAL_PRESENCE_CAT).label("category"),
|
|
130
|
+
literal(endpoint_constants.OPERATIONAL_PRESENCE_SUBCAT).label(
|
|
131
|
+
"subcategory"
|
|
132
|
+
),
|
|
130
133
|
DBLocation.name.label("location_name"),
|
|
131
134
|
DBLocation.code.label("location_code"),
|
|
132
135
|
DBAdmin1.name.label("admin1_name"),
|
|
@@ -15,6 +15,7 @@ from hapi_schema.db_admin1 import DBAdmin1
|
|
|
15
15
|
from hapi_schema.db_admin2 import DBAdmin2
|
|
16
16
|
from hapi_schema.db_location import DBLocation
|
|
17
17
|
from hapi_schema.db_resource import DBResource
|
|
18
|
+
from hapi_schema.utils import endpoint_constants
|
|
18
19
|
from hapi_schema.utils.base import Base
|
|
19
20
|
from hapi_schema.utils.constraints import (
|
|
20
21
|
max_age_constraint,
|
|
@@ -107,8 +108,8 @@ view_params_population = ViewParams(
|
|
|
107
108
|
# Results format: category, subcategory, location_name, location_code, admin1_name, admin1_code, admin2_name, admin2_code, hapi_updated_date
|
|
108
109
|
availability_stmt_population = (
|
|
109
110
|
select(
|
|
110
|
-
literal(
|
|
111
|
-
literal(
|
|
111
|
+
literal(endpoint_constants.POPULATION_CAT).label("category"),
|
|
112
|
+
literal(endpoint_constants.POPULATION_SUBCAT).label("subcategory"),
|
|
112
113
|
DBLocation.name.label("location_name"),
|
|
113
114
|
DBLocation.code.label("location_code"),
|
|
114
115
|
DBAdmin1.name.label("admin1_name"),
|
|
@@ -15,6 +15,7 @@ from sqlalchemy.sql.expression import literal
|
|
|
15
15
|
from hapi_schema.db_admin1 import DBAdmin1
|
|
16
16
|
from hapi_schema.db_location import DBLocation
|
|
17
17
|
from hapi_schema.db_resource import DBResource
|
|
18
|
+
from hapi_schema.utils import endpoint_constants
|
|
18
19
|
from hapi_schema.utils.base import Base
|
|
19
20
|
from hapi_schema.utils.constraints import (
|
|
20
21
|
percentage_constraint,
|
|
@@ -105,8 +106,8 @@ view_params_poverty_rate = ViewParams(
|
|
|
105
106
|
# Results format: category, subcategory, location_name, location_code, admin1_name, admin1_code, admin2_name, admin2_code, hapi_updated_date
|
|
106
107
|
availability_stmt_poverty_rate = (
|
|
107
108
|
select(
|
|
108
|
-
literal(
|
|
109
|
-
literal(
|
|
109
|
+
literal(endpoint_constants.POVERTY_RATE_CAT).label("category"),
|
|
110
|
+
literal(endpoint_constants.POVERTY_RATE_SUBCAT).label("subcategory"),
|
|
110
111
|
DBLocation.name.label("location_name"),
|
|
111
112
|
DBLocation.code.label("location_code"),
|
|
112
113
|
DBAdmin1.name.label("admin1_name"),
|
|
@@ -16,6 +16,7 @@ from sqlalchemy.sql.expression import literal
|
|
|
16
16
|
|
|
17
17
|
from hapi_schema.db_location import DBLocation
|
|
18
18
|
from hapi_schema.db_resource import DBResource
|
|
19
|
+
from hapi_schema.utils import endpoint_constants
|
|
19
20
|
from hapi_schema.utils.base import Base
|
|
20
21
|
from hapi_schema.utils.constraints import (
|
|
21
22
|
max_age_constraint,
|
|
@@ -112,8 +113,8 @@ view_params_refugees = ViewParams(
|
|
|
112
113
|
# Results format: category, subcategory, location_name, location_code, admin1_name, admin1_code, admin2_name, admin2_code, hapi_updated_date
|
|
113
114
|
availability_stmt_refugees = (
|
|
114
115
|
select(
|
|
115
|
-
literal(
|
|
116
|
-
literal(
|
|
116
|
+
literal(endpoint_constants.REFUGEES_CAT).label("category"),
|
|
117
|
+
literal(endpoint_constants.REFUGEES_SUBCAT).label("subcategory"),
|
|
117
118
|
DBLocation.name.label("location_name"),
|
|
118
119
|
DBLocation.code.label("location_code"),
|
|
119
120
|
literal("").label("admin1_name"),
|
|
@@ -126,7 +127,8 @@ availability_stmt_refugees = (
|
|
|
126
127
|
.select_from(
|
|
127
128
|
DBRefugees.__table__.join(
|
|
128
129
|
DBLocation.__table__,
|
|
129
|
-
DBRefugees.asylum_location_ref == DBLocation.id
|
|
130
|
+
(DBRefugees.asylum_location_ref == DBLocation.id)
|
|
131
|
+
| (DBRefugees.origin_location_ref == DBLocation.id),
|
|
130
132
|
isouter=True,
|
|
131
133
|
).join(
|
|
132
134
|
DBResource.__table__,
|
|
@@ -16,6 +16,7 @@ from sqlalchemy.sql.expression import literal
|
|
|
16
16
|
|
|
17
17
|
from hapi_schema.db_location import DBLocation
|
|
18
18
|
from hapi_schema.db_resource import DBResource
|
|
19
|
+
from hapi_schema.utils import endpoint_constants
|
|
19
20
|
from hapi_schema.utils.base import Base
|
|
20
21
|
from hapi_schema.utils.constraints import (
|
|
21
22
|
max_age_constraint,
|
|
@@ -112,8 +113,8 @@ view_params_returnees = ViewParams(
|
|
|
112
113
|
# Results format: category, subcategory, location_name, location_code, admin1_name, admin1_code, admin2_name, admin2_code, hapi_updated_date
|
|
113
114
|
availability_stmt_returnees = (
|
|
114
115
|
select(
|
|
115
|
-
literal(
|
|
116
|
-
literal(
|
|
116
|
+
literal(endpoint_constants.RETURNEES_CAT).label("category"),
|
|
117
|
+
literal(endpoint_constants.RETURNEES_SUBCAT).label("subcategory"),
|
|
117
118
|
DBLocation.name.label("location_name"),
|
|
118
119
|
DBLocation.code.label("location_code"),
|
|
119
120
|
literal("").label("admin1_name"),
|
|
@@ -126,7 +127,8 @@ availability_stmt_returnees = (
|
|
|
126
127
|
.select_from(
|
|
127
128
|
DBReturnees.__table__.join(
|
|
128
129
|
DBLocation.__table__,
|
|
129
|
-
DBReturnees.asylum_location_ref == DBLocation.id
|
|
130
|
+
(DBReturnees.asylum_location_ref == DBLocation.id)
|
|
131
|
+
| (DBReturnees.origin_location_ref == DBLocation.id),
|
|
130
132
|
isouter=True,
|
|
131
133
|
).join(
|
|
132
134
|
DBResource.__table__,
|
|
@@ -618,6 +618,7 @@ class DBWfpMarketVAT(Base):
|
|
|
618
618
|
admin2_name: Mapped[str] = mapped_column(String(512), index=True)
|
|
619
619
|
admin2_is_unspecified: Mapped[bool] = mapped_column(Boolean)
|
|
620
620
|
admin1_ref: Mapped[int] = mapped_column(Integer)
|
|
621
|
+
admin_level: Mapped[int] = mapped_column(Integer, index=True)
|
|
621
622
|
|
|
622
623
|
|
|
623
624
|
class DBAvailabilityVAT(Base):
|
|
@@ -9,6 +9,7 @@ from hapi_schema.db_location import DBLocation
|
|
|
9
9
|
from hapi_schema.utils.base import Base
|
|
10
10
|
from hapi_schema.utils.constraints import latlon_constraint
|
|
11
11
|
from hapi_schema.utils.view_params import ViewParams
|
|
12
|
+
from hapi_schema.views import get_admin2_case
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
class DBWFPMarket(Base):
|
|
@@ -50,6 +51,7 @@ view_params_wfp_market = ViewParams(
|
|
|
50
51
|
DBAdmin2.name.label("admin2_name"),
|
|
51
52
|
DBAdmin2.is_unspecified.label("admin2_is_unspecified"),
|
|
52
53
|
DBAdmin2.admin1_ref.label("admin1_ref"),
|
|
54
|
+
get_admin2_case(DBWFPMarket),
|
|
53
55
|
).select_from(
|
|
54
56
|
# Join market to admin2 to admin1 to loc
|
|
55
57
|
DBWFPMarket.__table__.join(
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"""
|
|
2
|
+
The constants below are used to create the category and subcategory names.
|
|
3
|
+
Be careful when changing them as these are used to create the endpoints.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
# categories
|
|
7
|
+
AFFECTED_PEOPLE = "affected-people"
|
|
8
|
+
COORDINATION_CONTEXT = "coordination-context"
|
|
9
|
+
FOOD_SECURITY = "food-security-nutrition-poverty"
|
|
10
|
+
GEOGRAPHY_INFRASTRUCTURE = "geography-infrastructure"
|
|
11
|
+
|
|
12
|
+
CONFLICT_EVENT_CAT = COORDINATION_CONTEXT
|
|
13
|
+
CONFLICT_EVENT_SUBCAT = "conflict-events"
|
|
14
|
+
FOOD_PRICE_CAT = FOOD_SECURITY
|
|
15
|
+
FOOD_PRICE_SUBCAT = "food-prices-market-monitor"
|
|
16
|
+
FOOD_SECURITY_CAT = FOOD_SECURITY
|
|
17
|
+
FOOD_SECURITY_SUBCAT = "food-security"
|
|
18
|
+
FUNDING_CAT = COORDINATION_CONTEXT
|
|
19
|
+
FUNDING_SUBCAT = "funding"
|
|
20
|
+
HUMANITARIAN_NEEDS_CAT = AFFECTED_PEOPLE
|
|
21
|
+
HUMANITARIAN_NEEDS_SUBCAT = "humanitarian-needs"
|
|
22
|
+
IDPS_CAT = AFFECTED_PEOPLE
|
|
23
|
+
IDPS_SUBCAT = "idps"
|
|
24
|
+
NATIONAL_RISK_CAT = COORDINATION_CONTEXT
|
|
25
|
+
NATIONA_RISK_SUBCAT = "national-risk"
|
|
26
|
+
OPERATIONAL_PRESENCE_CAT = COORDINATION_CONTEXT
|
|
27
|
+
OPERATIONAL_PRESENCE_SUBCAT = "operational-presence"
|
|
28
|
+
POPULATION_CAT = GEOGRAPHY_INFRASTRUCTURE
|
|
29
|
+
POPULATION_SUBCAT = "baseline-population"
|
|
30
|
+
POVERTY_RATE_CAT = FOOD_SECURITY
|
|
31
|
+
POVERTY_RATE_SUBCAT = "poverty-rate"
|
|
32
|
+
REFUGEES_CAT = AFFECTED_PEOPLE
|
|
33
|
+
REFUGEES_SUBCAT = "refugees-persons-of-concern"
|
|
34
|
+
RETURNEES_CAT = AFFECTED_PEOPLE
|
|
35
|
+
RETURNEES_SUBCAT = "returnees"
|
|
@@ -35,7 +35,7 @@ def test_conflict_event_availability(run_view_test):
|
|
|
35
35
|
view=view_availability,
|
|
36
36
|
whereclause=(
|
|
37
37
|
view_availability.c.category == "coordination-context",
|
|
38
|
-
view_availability.c.subcategory == "conflict-
|
|
38
|
+
view_availability.c.subcategory == "conflict-events",
|
|
39
39
|
view_availability.c.location_code == "FOO",
|
|
40
40
|
view_availability.c.admin1_name == "Province 01",
|
|
41
41
|
view_availability.c.admin2_name == "District A",
|
|
@@ -44,8 +44,8 @@ def test_food_price_availability(run_view_test):
|
|
|
44
44
|
run_view_test(
|
|
45
45
|
view=view_availability,
|
|
46
46
|
whereclause=(
|
|
47
|
-
view_availability.c.category == "food",
|
|
48
|
-
view_availability.c.subcategory == "food-
|
|
47
|
+
view_availability.c.category == "food-security-nutrition-poverty",
|
|
48
|
+
view_availability.c.subcategory == "food-prices-market-monitor",
|
|
49
49
|
view_availability.c.location_code == "FOO",
|
|
50
50
|
view_availability.c.admin1_name == "Province 01",
|
|
51
51
|
view_availability.c.admin2_name == "District A",
|
|
@@ -34,7 +34,7 @@ def test_food_security_availability(run_view_test):
|
|
|
34
34
|
run_view_test(
|
|
35
35
|
view=view_availability,
|
|
36
36
|
whereclause=(
|
|
37
|
-
view_availability.c.category == "food",
|
|
37
|
+
view_availability.c.category == "food-security-nutrition-poverty",
|
|
38
38
|
view_availability.c.subcategory == "food-security",
|
|
39
39
|
view_availability.c.location_code == "FOO",
|
|
40
40
|
view_availability.c.admin1_name == "Province 01",
|
|
@@ -32,8 +32,8 @@ def test_population_availability(run_view_test):
|
|
|
32
32
|
run_view_test(
|
|
33
33
|
view=view_availability,
|
|
34
34
|
whereclause=(
|
|
35
|
-
view_availability.c.category == "
|
|
36
|
-
view_availability.c.subcategory == "population",
|
|
35
|
+
view_availability.c.category == "geography-infrastructure",
|
|
36
|
+
view_availability.c.subcategory == "baseline-population",
|
|
37
37
|
view_availability.c.location_code == "FOO",
|
|
38
38
|
view_availability.c.admin1_name == "Province 01",
|
|
39
39
|
view_availability.c.admin2_name == "District A",
|
|
@@ -32,7 +32,7 @@ def test_poverty_rate_availability(run_view_test):
|
|
|
32
32
|
run_view_test(
|
|
33
33
|
view=view_availability,
|
|
34
34
|
whereclause=(
|
|
35
|
-
view_availability.c.category == "
|
|
35
|
+
view_availability.c.category == "food-security-nutrition-poverty",
|
|
36
36
|
view_availability.c.subcategory == "poverty-rate",
|
|
37
37
|
view_availability.c.location_code == "FOO",
|
|
38
38
|
view_availability.c.admin1_name == "Province 01",
|
|
@@ -29,9 +29,8 @@ def test_refugees_availability(run_view_test):
|
|
|
29
29
|
view=view_availability,
|
|
30
30
|
whereclause=(
|
|
31
31
|
view_availability.c.category == "affected-people",
|
|
32
|
-
view_availability.c.subcategory == "refugees",
|
|
33
|
-
view_availability.c.location_code
|
|
34
|
-
== "BAR", # we use the country of asylum, not origin
|
|
32
|
+
view_availability.c.subcategory == "refugees-persons-of-concern",
|
|
33
|
+
view_availability.c.location_code == "BAR",
|
|
35
34
|
view_availability.c.admin1_name == "",
|
|
36
35
|
view_availability.c.admin2_name == "",
|
|
37
36
|
view_availability.c.hapi_updated_date == datetime(2023, 8, 1),
|
|
@@ -30,8 +30,7 @@ def test_returnees_availability(run_view_test):
|
|
|
30
30
|
whereclause=(
|
|
31
31
|
view_availability.c.category == "affected-people",
|
|
32
32
|
view_availability.c.subcategory == "returnees",
|
|
33
|
-
view_availability.c.location_code
|
|
34
|
-
== "BAR", # we use the country of asylum, not origin
|
|
33
|
+
view_availability.c.location_code == "BAR",
|
|
35
34
|
view_availability.c.admin1_name == "",
|
|
36
35
|
view_availability.c.admin2_name == "",
|
|
37
36
|
view_availability.c.hapi_updated_date == datetime(2023, 8, 1),
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{hapi_schema-0.9.6 → hapi_schema-0.9.7}/src/hapi_schema/utils/view_as_table_code_generator.py
RENAMED
|
File without changes
|
{hapi_schema-0.9.6 → hapi_schema-0.9.7}/src/hapi_schema/utils/view_as_table_definitions.toml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|