Skip to content

BDMS 227: well additional information#267

Closed
jacob-a-brown wants to merge 152 commits into
stagingfrom
bdms-227
Closed

BDMS 227: well additional information#267
jacob-a-brown wants to merge 152 commits into
stagingfrom
bdms-227

Conversation

@jacob-a-brown

Copy link
Copy Markdown
Contributor

Why

This PR addresses the following problem / context:

  • This PR addresses the Gherkin file well-additional-information.feature by updating the API, schemas, models, and transfer scripts

How

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

  • Updated Response schemas: ThingResponse, WellResponse, LocationGeoJSONResponse
  • Updated some Create schemas for the transfer scripts: CreateWell, CreateLocation
  • Added Response schemas: PermissionResponse
  • Added new database models: GeologicFormation, AquiferSystem, AquiferType
  • Updated database models: Thing, Permission/PermissionHistory
  • Updated transfer scripts
  • Added new lexicon terms and enums

Notes

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

  • Used cls.__tablename__ for polymorphic table relationships in the mixins
  • The ThingAquiferAssocation model relates a Thing to an AquiferSystem. It also related AquiferTypes (e.g. characteristics), to the system at that well.
  • Formation and aquifer codes have been ported from NM_Aquifer, but they need to be cleaned up.
    • Formation names intentionally NOT stored in database; API will map formation codes to names using authoritative formations.json file that can be updated independently
  • start_date is not nullable for PermissionHistory records, but it is in the response schema so that all types of permissions for a well can be returned. If a particular permission type does not exist, it will be in the returned list of permissions, but everything evaluates to None. This essentially allows the user to determine if the permission does or does not exist.
  • Permissions was renamed PermissionHistory since it stores the history of permissions for an object (most often a Thing)
  • permissions need to be transferred after both wells and contacts are transferred since it requires IDs from both tables

Work (Kind of) Reviewed

We opened up PRs for smaller bits of work. They were reviewed, but this is the authoritative PR into staging. There are some notes and discussions in those PRs, so they're listed here for record-keeping:

Jira Tasks

Many Jira tasks, and subtasks, were addressed by this PR. They are:

  • BDMS-227
  • BDMS-229
  • BDMS-230
  • BDMS-231
  • BDMS-232
  • BDMS-254
  • BDMS-258

jacob-a-brown and others added 30 commits November 4, 2025 17:31
…s-227-231-additional-well-info-models

# Conflicts:
#	.pre-commit-config.yaml
#	core/lexicon.json
#	tests/features/environment.py
…abulary fields

- Implemented `AquiferSystem` model for master reference of aquifer systems and hydrogeologic units
- Added table index for aquifer system name
- Included categories and terms for aquifer type and significance level
jacob-a-brown and others added 21 commits December 1, 2025 15:27
the terminal/std out often cuts off error messages. calling
e.errors() ensures we get the full error message
We originally used new types, but for the transfer to work legacy
terms need to be used. The meanings were in the definition, but now
they are terms.
the column names for LU_Lithology are not standard and need to be
accounted for individually
log the errors as critical and append to errors so that
the metrics and logs can be parsed correctly
log them as critical and add to errors for correct
metric and log handling/reporting
…pdates

BDMS 227: permission & well pump type transfer fix
- Delegate WKT boundary validation to `services/validation/geospatial.py` to enforce topological validity.
- Update `CreateAquiferSystem` and `CreateGeologicFormation` to enforce strict Enum typing for controlled vocabularies, removing loose string coercion.
`top_depth` and `bottom_depth` are required so the None check is redundant.

Remove the None check.
- Remove manual `if` validation logic for non-negative depths in `DepthIntervalMixin`.
- Implement `Field(ge=0)` on `top_depth` and `bottom_depth` to leverage Pydantic's native schema validation and cleaner OpenAPI generation.
- Ensure `CreateThingGeologicFormationAssociation` inherits these constraints by explicitly redefining fields with `ge=0`.
…chema-validations

# Conflicts:
#	schemas/aquifer_system.py
…ema-validations-aquifer-geology

BDMS-227-254: add schema validations to aquifer and geology schemas
since the mixins also inherit from BaseModel, inheriting from both
BaseModel and the mixins causes issues with pydantic's model resolution order.
@codecov-commenter

codecov-commenter commented Dec 2, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.33333% with 15 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
schemas/thing.py 87.50% 7 Missing ⚠️
services/util.py 63.63% 4 Missing ⚠️
db/thing.py 91.66% 3 Missing ⚠️
db/permission_history.py 95.83% 1 Missing ⚠️
Files with missing lines Coverage Δ
core/enums.py 100.00% <100.00%> (ø)
db/__init__.py 98.03% <100.00%> (+0.36%) ⬆️
db/aquifer_system.py 100.00% <100.00%> (ø)
db/aquifer_type.py 100.00% <100.00%> (ø)
db/base.py 96.15% <ø> (-0.46%) ⬇️
db/contact.py 100.00% <100.00%> (ø)
db/data_provenance.py 93.33% <100.00%> (ø)
db/geologic_formation.py 100.00% <100.00%> (ø)
db/notes.py 95.23% <ø> (ø)
db/status_history.py 100.00% <100.00%> (ø)
... and 9 more

... and 21 files with indirect coverage changes

@jirhiker

jirhiker commented Dec 3, 2025

Copy link
Copy Markdown
Member

this changes were manuallly merged into PR #262

@jirhiker jirhiker closed this Dec 3, 2025
@ksmuczynski ksmuczynski deleted the bdms-227 branch March 25, 2026 17:30
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.

4 participants