Skip to content

fix(well-inventory): set observation release status (BDMS-1559) - #1053

Open
ksmuczynski wants to merge 2 commits into
stagingfrom
fix/well-inventory-observation-release-status-BDMS-1559
Open

ksmuczynski wants to merge 2 commits into
stagingfrom
fix/well-inventory-observation-release-status-BDMS-1559

Conversation

@ksmuczynski

@ksmuczynski ksmuczynski commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR makes the well inventory importer give each groundwater level observation it creates the same release status as its well. After this change, an observation the importer creates for a public well appears in the public EDR waterlevels collection.

Why

This PR addresses the following problem / context:

  • The well inventory importer leaves each groundwater level observation as draft, even on a public well. ogc_waterlevels shows an observation only when both the observation and its well are public, so these observations never appear there.

How

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

  • Added observation_release_status to domain/water_levels.py. It returns the well's status when that status is public or private, and draft otherwise.
  • Set the observation's release status with that function in services/well_inventory_csv.py.
  • Added tests for observation_release_status.
  • Added an import test for each answer the owner can give to the public availability acknowledgement (True, False and blank). The test checks that ogc_waterlevels includes the observation when the answer is True, and does not include it when the answer is False or blank.

Notes

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

  • The importer sets the status only on the observation. Its sample, field activity and field event stay draft. The NGWMN water level export (NGWMN_WaterLevels) requires those three records to be public as well, so it does not include these observations. NGWMN is left for a separate ticket.
  • Other public layers that select only public observations will now select these observations too. For example, last_observation_date on the public water_wells layer now includes them. Materialized layers, such as ogc_well_water_column, include them after their next refresh.
  • Verified. On this branch, 1726 tests pass.

Refs BDMS-1559

The well inventory importer sets the well's release status based on
the owner's answer to "Owner acknowledges data will be publicly
available", but it leaves the groundwater level observation as draft.
The public EDR waterlevels collection (ogc_waterlevels) shows an
observation only when both the observation and its well are public.
So the collection hides this importer's observations, even on public
wells.

The importer now gives each observation it creates the same release
status as its well, whether public, private or draft. The BDMS-1561
backfill applies this rule to the observations this importer created
before this fix, so old and new well inventory observations follow it.

The rule is in a new domain function, observation_release_status.
The water level CSV importer also leaves its observations as draft,
and a separate PR will fix that importer using the same function.

observation_release_status copies the well's status when it is public
or private, and returns draft for any other status. Public and
private are the only statuses that indicate whether the well's data
may be published. In this importer the well is always new, so its
status is always public, private or draft. The water level CSV
importer adds observations to existing wells, so it will be the only
caller to pass other statuses.

The importer sets the observation's status once, when it creates the
observation. If staff later make a draft well public, its imported
observations stay draft, and the EDR collection keeps hiding them
until someone makes them public too. Making a public well private
does hide its observations, because the EDR collection also checks
the well's status.

Refs BDMS-1559
Before this fix, the tests gave these results:
- The importer test failed when the owner answered True or False. The
  importer left the observation as draft, and the test expects public
  or private.
- The importer test passed when the owner left the answer blank. The
  importer already left that observation as draft, which is the
  correct status. This case will fail if a later change gives that
  observation any other status.
- The domain tests could not run, because observation_release_status
  did not exist.

The domain tests check that observation_release_status:
- Copies public, private and draft.
- Returns draft for no status, an empty string, and provisional,
  final, published and archived.
- Returns draft for "Public" with a capital P. The views compare the
  exact lowercase value, so they would not treat that well as public
  either.

The importer test imports one row with a water level for each owner
answer (True, False and blank). It checks that:
- The observation's status is public, private or draft, and equals the
  well's.
- The sample, field activity and field event stay draft.
- The observation appears in ogc_waterlevels only when the answer is
  True. The fix exists to make these observations appear there, so the
  test checks the collection itself. A later change to the view's
  filter that hides them fails the test.

Refs BDMS-1559
@ksmuczynski ksmuczynski self-assigned this Nov 13, 2026
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Coverage

✅ 82.03% total — gate is 75%.

Coverage for the Python files changed in this PR
Name Stmts Miss Cover Missing
domain/water_levels.py 27 0 100%
services/well_inventory_csv.py 306 20 93% 94, 156-159, 262-265, 267-269, 310-312, 346-348, 546, 581, 819-826
TOTAL 333 20 94%

@github-actions

Copy link
Copy Markdown
Contributor

Your pull request is automatically being deployed to Dagster Cloud.

Location Status Link Updated
ocotillo-automated-ingestion View in Cloud Nov 13, 2026 at 05:58 PM (UTC)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block the observation release-status change.

No open issues 🎉

What changed in this PR

This PR fixes release-status handling in the well inventory importer so newly imported groundwater level observations on public wells can appear in the public EDR waterlevels collection.

Changes:

  • Adds a domain rule that copies public/private well status to observations and defaults other statuses to draft.
  • Applies the rule when creating observations, leaving sample and visit records unchanged.
  • Adds unit and import tests covering release statuses and visibility in ogc_waterlevels.
File Description
tests/​test_well_inventory.py Tests observation status and public collection visibility for each acknowledgement response.
tests/​test_domain_water_levels.py Tests copied statuses and draft fallback behavior.
services/​well_inventory_csv.py Sets new observations’ release status from their well.
domain/​water_levels.py Defines the observation release-status rule.

Review effort: Balanced

@ksmuczynski
ksmuczynski added this pull request to stack #1056 November 13, 2026 21:39

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants