Conversation
There was a problem hiding this comment.
Pull request overview
This PR expands the OGC/pygeoapi feature collections for well analytics by adding new SQL views/materialized views, wiring them into the pygeoapi config, and improving runtime OpenAPI generation and CLI refresh behavior.
Changes:
- Add new OGC views/materialized views for latest/avg TDS, depth-to-water trend classification, and water well summary metrics.
- Update pygeoapi runtime/config to expose the new collections and generate OpenAPI via pygeoapi at startup.
- Update CLI refresh defaults and add/adjust tests for OpenAPI and TDS date fallback logic.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
alembic/versions/d5e6f7a8b9c0_create_pygeoapi_supporting_views.py |
Updates existing pygeoapi supporting views (schema cleanup + avg TDS date fields). |
alembic/versions/i2b3c4d5e6f7_add_latest_tds_pygeoapi_materialized_view.py |
Adds ogc_latest_tds_wells (view) and redefines ogc_avg_tds_wells (matview). |
alembic/versions/k4d5e6f7a8b9_add_depth_to_water_trend_materialized_view.py |
Adds depth-to-water trend classification materialized view. |
alembic/versions/l5e6f7a8b9c0_add_water_well_summary_materialized_view.py |
Adds water well summary materialized view. |
core/pygeoapi-config.yml |
Registers new OGC collections/providers in pygeoapi config. |
core/pygeoapi.py |
Uses pygeoapi to generate OpenAPI and improves DB env var fallback. |
cli/cli.py |
Expands default list of materialized views to refresh. |
tests/test_cli_commands.py |
Updates CLI refresh default expectations/count. |
tests/test_ogc.py |
Adds OpenAPI presence test + TDS observation date fallback integration test. |
Comments suppressed due to low confidence (1)
alembic/versions/i2b3c4d5e6f7_add_latest_tds_pygeoapi_materialized_view.py:6
- The migration module docstring and filename say “materialized view”, but
upgrade()createsogc_latest_tds_wellsas a regularCREATE VIEW(and explicitly drops any prior materialized view). This is misleading for future maintainers/operators who may expect it to be refreshable/handled like a matview. Update the docstring (and ideally the migration filename if feasible) to reflect thatogc_latest_tds_wellsis intentionally a non-materialized view.
"""add latest tds pygeoapi materialized view
Revision ID: i2b3c4d5e6f7
Revises: d5e6f7a8b9c0
Create Date: 2026-03-02 11:00:00.000000
"""
alembic/versions/i2b3c4d5e6f7_add_latest_tds_pygeoapi_materialized_view.py
Show resolved
Hide resolved
alembic/versions/l5e6f7a8b9c0_add_water_well_summary_materialized_view.py
Show resolved
Hide resolved
alembic/versions/i2b3c4d5e6f7_add_latest_tds_pygeoapi_materialized_view.py
Show resolved
Hide resolved
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b33700dd3d
ℹ️ 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".
… and add tests for timestamp accuracy
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
alembic/versions/i2b3c4d5e6f7_add_latest_tds_pygeoapi_materialized_view.py:5
- The migration docstring/file name says "materialized view", but this migration creates
ogc_latest_tds_wellsas a regularVIEW(onlyogc_avg_tds_wellsis materialized). Please rename/update the docstring (and ideally the filename) to match what’s actually created so future operators don’t refresh/maintain the wrong object type.
"""add latest tds pygeoapi materialized view
Revision ID: i2b3c4d5e6f7
Revises: d5e6f7a8b9c0
Create Date: 2026-03-02 11:00:00.000000
alembic/versions/i2b3c4d5e6f7_add_latest_tds_pygeoapi_materialized_view.py
Outdated
Show resolved
Hide resolved
…ized_view.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
core/pygeoapi.py:296
- The PR description mentions a
PYGEOAPI_POSTGRES_*→POSTGRES_*fallback for DB env vars, but_pygeoapi_db_settings()still requiresPYGEOAPI_POSTGRES_PASSWORDspecifically and does not fall back toPOSTGRES_PASSWORD. If a deployment only setsPOSTGRES_PASSWORD, pygeoapi config generation will still fail.
Consider either (a) adding a password fallback to POSTGRES_PASSWORD and choosing the corresponding placeholder (${POSTGRES_PASSWORD} vs ${PYGEOAPI_POSTGRES_PASSWORD}), or (b) updating the PR description/docs to clarify that only host/port/db/user fall back.
if os.environ.get("PYGEOAPI_POSTGRES_PASSWORD") is None:
raise RuntimeError(
"PYGEOAPI_POSTGRES_PASSWORD must be set to "
"generate the pygeoapi configuration."
)
return host, port, dbname, user, "${PYGEOAPI_POSTGRES_PASSWORD}"
Summary
Adds new OGC/pygeoapi well analytics views and updates existing OGC support views/config, including:
What Changed
1. New/updated Alembic OGC views
Updated existing pygeoapi supporting views migration:
alembic/versions/d5e6f7a8b9c0_create_pygeoapi_supporting_views.pylocation.elevationto Thing collection viewsspring_typeandthing_typefrom Thing collection projections_datenaming (first_tds_observation_date,last_tds_observation_date)Added latest/avg TDS migration:
alembic/versions/i2b3c4d5e6f7_add_latest_tds_pygeoapi_materialized_view.pyogc_latest_tds_wellsis a view (not materialized)ogc_avg_tds_wellsremains a materialized viewCOALESCE(AnalysisDate, CollectionDate)for TDS observation date logiclatest_tds_observation_dateAdded depth-to-water trend materialized view:
alembic/versions/k4d5e6f7a8b9_add_depth_to_water_trend_materialized_view.pyogc_depth_to_water_trend_wells>=10records OR (>=4records AND span>=2years)> 0.25ft/yr:increasing< -0.25ft/yr:decreasingstablenot enough dataAdded water well summary materialized view:
alembic/versions/l5e6f7a8b9c0_add_water_well_summary_materialized_view.pyogc_water_well_summaryincludes:thing.namewell_depthelevationelevation_methodformation_zonetotal_water_levelslast_water_levellast_water_level_datetimemin_water_levelmax_water_levelwater_level_trend_ft_per_yeartotal_water_levels = 02. pygeoapi config updates
core/pygeoapi-config.ymllatest_tds_wellsdepth_to_water_trend_wellswater_well_summaryLatest Depth to Water (Wells)->Latest Depth to Water (Water Wells)3. pygeoapi runtime OpenAPI generation fix
core/pygeoapi.pyPYGEOAPI_POSTGRES_*->POSTGRES_*)4. CLI refresh defaults and tests
cli/cli.pyrefresh-pygeoapi-materialized-viewsdefault set now includes:ogc_latest_depth_to_water_wellsogc_avg_tds_wellsogc_depth_to_water_trend_wellsogc_water_well_summaryogc_latest_tds_wellsremoved from refresh defaults (it is a regular view)Tests updated:
tests/test_cli_commands.pytests/test_ogc.pyNotes / Compatibility
ogc_latest_tds_wellsis intentionally a non-materialized view._date(not_datetime) for TDS date outputs.Verification
l5e6f7a8b9c0.