Skip to content

[BDMS-123]: Add UTC normalization for date_time and measurement_date_time in well inventory importer#653

Merged
TylerAdamMartinez merged 13 commits into
stagingfrom
TAM-BDMS-718
Apr 17, 2026
Merged

[BDMS-123]: Add UTC normalization for date_time and measurement_date_time in well inventory importer#653
TylerAdamMartinez merged 13 commits into
stagingfrom
TAM-BDMS-718

Conversation

@TylerAdamMartinez

@TylerAdamMartinez TylerAdamMartinez commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

Why

This PR addresses the following problem/context:

  • measurement_date_time in the well inventory importer was not normalized to UTC before being written to sample.sample_date and observation.observation_datetime

How

Implementation summary - the following was changed/added/removed:

  • Extracted a reusable normalize_datetime_to_utc() helper into a shared utility module
  • Updated WellInventoryRow schema validators:
    • date_time is now normalized to UTC
    • measurement_date_time is now normalized to UTC
  • Removed logic that rejected timezone-aware datetimes; now both naive and aware datetimes are supported
  • Ensured naive datetimes are interpreted as America/Denver before conversion to UTC
  • Minor updates to schemas/water_level_csv.py to reuse the shared helper and keep validator behavior consistent (no intentional changes to water-level importer behavior)

Notes

Any special considerations, workarounds, or follow-up work to note?

  • Existing well inventory records may contain non-UTC datetimes; backfill or correction may be needed
  • Shared helper can now be reused by other importers to enforce consistent datetime handling
  • No database schema changes required

@TylerAdamMartinez TylerAdamMartinez self-assigned this Apr 15, 2026
@TylerAdamMartinez TylerAdamMartinez added the bug Something isn't working label Apr 15, 2026
@TylerAdamMartinez TylerAdamMartinez changed the title **WIP** [BDMS-123]: Add UTC normalization for date_time and measurement_date_time in well inventory importer [BDMS-123]: Add UTC normalization for date_time and measurement_date_time in well inventory importer Apr 16, 2026
@ksmuczynski

Copy link
Copy Markdown
Contributor

Looks great! The schema-level approach makes sense here. Just a few minor comments/suggestions, all optional.

  1. Consider adding a note to the PR description clarifying that the updates to schemas/water_level_csv.py are just to keep the validator behavior consistent and reuse the shared helper. Just want to make it clear we're not intentionally changing the water-level importer's core behavior.
  2. Since the PR now accepts timezone-aware datetimes as input, it'd be great to have an explicit WellInventoryRow test covering an aware date_time/measurement_date_time value alongside the existing naive-input coverage. That would help ensure the aware-datetime path stays covered going forward.
  3. I noticed the well-inventory feature/spec still describes the datetime inputs as timezone-naive only (tests/features/well-inventory-csv.feature, line 143). Consider aligning the docs with the implementation to avoid any confusion down the line.

@TylerAdamMartinez

TylerAdamMartinez commented Apr 17, 2026

Copy link
Copy Markdown
Contributor Author

Looks great! The schema-level approach makes sense here. Just a few minor comments/suggestions, all optional.

  1. Consider adding a note to the PR description clarifying that the updates to schemas/water_level_csv.py are just to keep the validator behavior consistent and reuse the shared helper. Just want to make it clear we're not intentionally changing the water-level importer's core behavior.
  2. Since the PR now accepts timezone-aware datetimes as input, it'd be great to have an explicit WellInventoryRow test covering an aware date_time/measurement_date_time value alongside the existing naive-input coverage. That would help ensure the aware-datetime path stays covered going forward.
  3. I noticed the well-inventory feature/spec still describes the datetime inputs as timezone-naive only (tests/features/well-inventory-csv.feature, line 143). Consider aligning the docs with the implementation to avoid any confusion down the line.
  • Add PR description node
  • Add an explicit WellInventoryRow test covering an aware date_time/measurement_date_time value alongside the existing naive-input coverage
  • Update the well-inventory-csv.feature

@TylerAdamMartinez TylerAdamMartinez merged commit 95e5a44 into staging Apr 17, 2026
5 checks passed
@TylerAdamMartinez TylerAdamMartinez deleted the TAM-BDMS-718 branch April 17, 2026 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants