Skip to content

Add actively monitored wells OGC collection#613

Merged
jirhiker merged 2 commits intostagingfrom
codex/ogc-actively-monitored
Mar 20, 2026
Merged

Add actively monitored wells OGC collection#613
jirhiker merged 2 commits intostagingfrom
codex/ogc-actively-monitored

Conversation

@jirhiker
Copy link
Member

Summary

  • add an actively_monitored_wells OGC collection backed by ogc_actively_monitored_wells
  • define the collection as a plain view over ogc_water_well_summary filtered to the Water Level Network group
  • remove deprecated well-type collections from the runtime pygeoapi config and add a forward Alembic migration that drops the corresponding ogc_* views in upgraded databases

Details

  • r2s3t4u5v6w7 creates ogc_actively_monitored_wells as a normal view, validates that the required group tables exist, and requires ogc_water_well_summary to be present
  • s4t5u6v7w8x9 drops the obsolete well-type OGC views on upgrade and recreates them on downgrade
  • the pygeoapi runtime config now mounts actively_monitored_wells and no longer mounts the removed well-type collections
  • the OGC tests were updated to build the app client explicitly and verify that wells in the Water Level Network group appear in the new collection

Validation

  • black alembic/versions/d5e6f7a8b9c0_create_pygeoapi_supporting_views.py alembic/versions/s4t5u6v7w8x9_drop_unused_well_type_ogc_views.py
  • flake8 alembic/versions/d5e6f7a8b9c0_create_pygeoapi_supporting_views.py alembic/versions/s4t5u6v7w8x9_drop_unused_well_type_ogc_views.py
  • pytest tests/integration/test_alembic_migrations.py -k "multiple_heads or current_revision_matches_head" -q
  • pytest tests/test_ogc.py -q

@jirhiker jirhiker changed the base branch from main to staging March 20, 2026 00:29
@chatgpt-codex-connector
Copy link

💡 Codex Review

FROM "group" AS g
JOIN group_thing_association AS gta ON gta.group_id = g.id
JOIN ogc_water_well_summary AS wws ON wws.id = gta.thing_id
WHERE lower(trim(g.name)) = 'water level network'

P1 Badge Filter the active-wells view by current monitoring status

When a project group contains wells whose latest Monitoring Status is Not currently monitored, this view still publishes them because it only filters on g.name. ProjectGroupTransferer._step() adds every prefixed well to the Water Level Network group and only uses monitoring status to set the group's type (transfers/group_transfer.py:57-83), so /ogcapi/collections/actively_monitored_wells will over-report inactive wells in normal production data.


JOIN ogc_water_well_summary AS wws ON wws.id = gta.thing_id

P2 Badge Stop excluding active wells that have no observations yet

This inner join makes the collection depend on ogc_water_well_summary, and that materialized view keeps only wells with at least one groundwater-level observation (l5e6f7a8b9c0_add_water_well_summary_materialized_view.py:98-115). A well can already be Currently monitored before its first reading is loaded (transfers/well_transfer.py:777-791), so newly onboarded active wells disappear from this OGC collection until after the first observation arrives.


gta = GroupThingAssociation(group=group, thing=record)
session.add(gta)
group.thing_associations.append(gta)

P1 Badge De-duplicate group memberships during project transfer

On any rerun of ProjectGroupTransferer, these statements create a fresh GroupThingAssociation for every matching thing without checking whether the link already exists. group_thing_association has no uniqueness constraint (db/group.py:63-76), so repeated transfers duplicate memberships and any group-based consumer—including ogc_actively_monitored_wells—can emit the same well multiple times.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@jirhiker jirhiker merged commit 1e4cbd4 into staging Mar 20, 2026
3 checks passed
@jirhiker jirhiker deleted the codex/ogc-actively-monitored branch March 20, 2026 02:43
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.

1 participant