Skip to content

Commit

Permalink
Merge pull request #64 from OCHA-DAP/HDXDSYS-843-add-dtm-bugfix
Browse files Browse the repository at this point in the history
HDXDSYS-843 add params and PKs to IDP
  • Loading branch information
turnerm authored Sep 19, 2024
2 parents 744423d + 4b0081c commit 5a92a14
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 3 deletions.
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ 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/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.8.17

### Added

- `operation` and additional primary keys to `idps` table

## 0.8.16

### Added
Expand Down
6 changes: 4 additions & 2 deletions src/hapi_schema/db_idps.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
DateTime,
ForeignKey,
Integer,
String,
select,
)
from sqlalchemy.orm import Mapped, mapped_column, relationship
Expand Down Expand Up @@ -46,14 +47,15 @@ class DBIDPs(Base):
build_enum_using_values(DTMAssessmentType), primary_key=True
)

reporting_round: Mapped[int] = mapped_column(Integer, nullable=True)
reporting_round: Mapped[int] = mapped_column(Integer, primary_key=True)
operation: Mapped[str] = mapped_column(String, primary_key=True)

population: Mapped[int] = mapped_column(
Integer, nullable=False, index=True
)

reference_period_start: Mapped[datetime] = mapped_column(
DateTime, nullable=False, index=True
DateTime, primary_key=True
)

reference_period_end: Mapped[datetime] = mapped_column(
Expand Down
3 changes: 2 additions & 1 deletion src/hapi_schema/db_views_as_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,8 @@ class DBIDPsVAT(Base):
resource_hdx_id: Mapped[str] = mapped_column(String(36))
admin2_ref: Mapped[int] = mapped_column(Integer, primary_key=True)
assessment_type: Mapped[str] = mapped_column(String(32), primary_key=True)
reporting_round: Mapped[int] = mapped_column(Integer, nullable=True)
reporting_round: Mapped[int] = mapped_column(Integer, primary_key=True)
operation: Mapped[str] = mapped_column(String, primary_key=True)
population: Mapped[int] = mapped_column(Integer, index=True)
reference_period_start: Mapped[datetime] = mapped_column(
DateTime, primary_key=True
Expand Down
1 change: 1 addition & 0 deletions tests/sample_data/data_idps.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
admin2_ref=2,
assessment_type="BA",
reporting_round=18,
operation="Operation",
population=25000,
reference_period_start=datetime(2024, 1, 1),
reference_period_end=datetime(2024, 12, 31),
Expand Down
2 changes: 2 additions & 0 deletions tests/test_idps.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def test_idps_view(run_view_test):
view_idps.c.admin2_ref == 2,
view_idps.c.assessment_type == "BA",
view_idps.c.reporting_round == 18,
view_idps.c.operation == "Operation",
view_idps.c.population == 25000,
view_idps.c.admin2_code == "FOO-001-XXX",
view_idps.c.admin1_code == "FOO-001",
Expand Down Expand Up @@ -51,6 +52,7 @@ def base_parameters():
admin2_ref=2,
assessment_type="BA",
reporting_round=18,
operation="operation",
population=25000,
reference_period_start=datetime(2020, 1, 1),
reference_period_end=datetime(2020, 1, 2),
Expand Down
2 changes: 2 additions & 0 deletions tests/test_views_as_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ def test_idps_vat(run_indexes_test, run_columns_test, run_primary_keys_test):
expected_primary_keys = [
"admin2_ref",
"assessment_type",
"reporting_round",
"operation",
"reference_period_start",
]
expected_indexes = [
Expand Down

0 comments on commit 5a92a14

Please sign in to comment.