Skip to content

Commit 047e2fa

Browse files
authored
Merge pull request #272 from DataIntegrationGroup/bdms-233-notes-transfer-and-updates
BDMS 233: notes transfer and updates
2 parents 47a10b2 + 35f329e commit 047e2fa

21 files changed

Lines changed: 404 additions & 41 deletions

core/lexicon.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1166,9 +1166,10 @@
11661166
{"categories": ["note_type"], "term": "Construction", "definition": "Construction details, well development, drilling notes, etc. Could create separate `types` for each of these if needed."},
11671167
{"categories": ["note_type"], "term": "Maintenance", "definition": "Maintenance observations and issues."},
11681168
{"categories": ["note_type"], "term": "Historical", "definition": "Historical information or context about the well or location."},
1169-
{"categories": ["note_type"], "term": "Other", "definition": "Other types of notes that do not fit into the predefined categories."},
1169+
{"categories": ["note_type"], "term": "General", "definition": "Other types of notes that do not fit into the predefined categories."},
11701170
{"categories": ["note_type"], "term": "Water", "definition": "Water bearing zone information and other info from ose reports"},
11711171
{"categories": ["note_type"], "term": "Measuring", "definition": "Notes about measuring/visiting the well, on Access form"},
1172+
{"categories": ["note_type"], "term": "Coordinate", "definition": "Notes about a location's coordinates"},
11721173
{"categories": ["well_pump_type"], "term": "Submersible", "definition": "Submersible"},
11731174
{"categories": ["well_pump_type"], "term": "Jet", "definition": "Jet Pump"},
11741175
{"categories": ["well_pump_type"], "term": "Line Shaft", "definition": "Line Shaft"},

db/thing.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# ===============================================================================
1616
from typing import List, TYPE_CHECKING
1717
from datetime import date
18-
from sqlalchemy import Integer, ForeignKey, String, Column, Float, Text, Date
18+
from sqlalchemy import Integer, ForeignKey, String, Column, Float, Date
1919
from sqlalchemy.ext.associationproxy import association_proxy, AssociationProxy
2020
from sqlalchemy.orm import relationship, mapped_column, Mapped
2121
from sqlalchemy_utils import TSVectorType
@@ -117,8 +117,6 @@ class Thing(
117117
comment="Depth of the well casing from ground surface to the bottom of the casing (in feet).",
118118
)
119119

120-
well_construction_notes: Mapped[str] = mapped_column(Text, nullable=True)
121-
122120
well_completion_date: Mapped[date] = mapped_column(
123121
nullable=True, comment="the date the well was completed if known"
124122
)
@@ -348,7 +346,7 @@ class Thing(
348346
)
349347

350348
# Full-text search vector
351-
search_vector = Column(TSVectorType("name", "well_construction_notes"))
349+
search_vector = Column(TSVectorType("name"))
352350

353351
@property
354352
def current_location(self):
@@ -372,12 +370,16 @@ def water_notes(self):
372370

373371
@property
374372
def general_notes(self):
375-
return self._get_notes("Other")
373+
return self._get_notes("General")
376374

377375
@property
378376
def measuring_notes(self):
379377
return self._get_notes("Measuring")
380378

379+
@property
380+
def construction_notes(self):
381+
return self._get_notes("Construction")
382+
381383
@property
382384
def well_status(self) -> str | None:
383385
"""

schemas/thing.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ class CreateWell(CreateBaseThing, ValidateWell):
123123
hole_depth: float | None = Field(
124124
default=None, gt=0, description="Hole depth in feet"
125125
)
126-
well_construction_notes: str | None = None
127126
well_casing_diameter: float | None = Field(
128127
default=None, gt=0, description="Well casing diameter in inches"
129128
)
@@ -194,13 +193,11 @@ class BaseThingResponse(BaseResponseModel):
194193
thing_type: str
195194
current_location: LocationGeoJSONResponse
196195
first_visit_date: PastOrTodayDate | None
197-
# The new relationship to the polymorphic Notes table
198-
notes: List[NoteResponse] = []
199-
200196
groups: list[GroupResponse] = []
201197
monitoring_status: str | None
202198
links: list[ThingIdLinkResponse] = Field(default=[], alias="alternate_ids")
203199
monitoring_frequencies: list[MonitoringFrequencyResponse] = []
200+
general_notes: list[NoteResponse] | None = None
204201

205202
@field_validator("monitoring_frequencies", mode="before")
206203
def remove_records_with_end_date(cls, monitoring_frequencies):
@@ -233,7 +230,6 @@ class WellResponse(BaseThingResponse):
233230
well_casing_depth: float | None = None
234231
well_casing_depth_unit: str = "ft"
235232
well_casing_materials: list[CasingMaterial] = []
236-
well_construction_notes: str | None = None
237233
well_completion_date: PastOrTodayDate | None
238234
well_completion_date_source: str | None
239235
well_driller_name: str | None
@@ -250,7 +246,8 @@ class WellResponse(BaseThingResponse):
250246
aquifers: list[dict] = []
251247
water_notes: list[NoteResponse] | None = None
252248
measuring_notes: list[NoteResponse] | None = None
253-
general_notes: list[NoteResponse] | None = None
249+
250+
construction_notes: list[NoteResponse] | None = None
254251
permissions: list[PermissionHistoryResponse]
255252
formation_completion_code: FormationCode | None
256253

tests/conftest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ def water_well_thing(location):
5757
release_status="draft",
5858
well_depth=10,
5959
hole_depth=10,
60-
well_construction_notes="Test well construction notes",
6160
well_casing_diameter=5.0,
6261
well_casing_depth=10.0,
6362
)

tests/features/environment.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def add_location(context, session):
7474
session.add(loc)
7575
session.commit()
7676
session.refresh(loc)
77-
n = loc.add_note("Test location", "Other")
77+
n = loc.add_note("Test location", "General")
7878
session.add(n)
7979
session.commit()
8080
session.refresh(loc)
@@ -92,7 +92,6 @@ def add_well(context, session, location, name_num):
9292
release_status="draft",
9393
well_depth=10,
9494
hole_depth=10,
95-
well_construction_notes="Test well construction notes",
9695
well_casing_diameter=5.0,
9796
well_casing_depth=10.0,
9897
well_completion_date="2013-05-15",
@@ -114,9 +113,10 @@ def add_well(context, session, location, name_num):
114113
session.refresh(well)
115114

116115
for nt, c in (
117-
("Other", "well notes"),
116+
("General", "well notes"),
118117
("Water", "water notes"),
119118
("Measuring", "measuring notes"),
119+
("Construction", "construction notes"),
120120
):
121121
n = well.add_note(c, nt)
122122
session.add(n)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Created by jakeross at 10/22/25
2+
@backend @production
3+
Feature: Geojson Response
4+
# Enter feature description here
5+
Background:
6+
Given a functioning api
7+
And the system has valid well and location data in the database
8+
9+
@positive @happy_path
10+
Scenario: Request all wells as geojson
11+
When the user requests all the wells as geojson
12+
Then the system should return a 200 status code
13+
And the system should return a response in GEOJSON format
14+
And the response should be a feature collection
15+
And the feature collection should have 3 features
16+
17+
@positive @happy_path
18+
Scenario: Request all wells in a group as geojson
19+
When the user requests all the wells for group Collabnet
20+
Then the system should return a 200 status code
21+
And the system should return a response in GEOJSON format
22+
And the response should be a feature collection
23+
And the feature collection should have 2 features
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Created by jakeross at 10/21/25
2+
@backend @BDMS-199 @production
3+
Feature: Retrieve location notes by well name
4+
As a user
5+
I want to retrieve location notes for a given well name
6+
So that I can view important information about the well's location
7+
Background:
8+
Given a functioning api
9+
And the system has valid well and location data in the database
10+
11+
@positive @happy_path
12+
Scenario: Retrieve location notes for an existing well
13+
When the user retrieves the well by ID via path parameter
14+
Then the system should return a 200 status code
15+
And the system should return a response in JSON format
16+
And the response should include a current location
17+
And the current location should include notes
18+
And the notes should be a list of dictionaries
19+
And each note dictionary should have "content" and "note_type" keys
20+
And each note in the notes list should be a non-empty string
21+
22+
@positive @happy_path
23+
Scenario: Retrieve location notes by location ID
24+
When the user retrieves the location by ID via path parameter
25+
Then the system should return a 200 status code
26+
And the system should return a response in JSON format
27+
And the location response should include notes
28+
And the notes should be a list of dictionaries
29+
And each note dictionary should have "content" and "note_type" keys
30+
And each note in the notes list should be a non-empty string
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
@backend @BDMS-169
2+
Feature: Unified search API returns grouped results
3+
As a user
4+
I want to search for contacts, wells, and springs
5+
So that I can quickly find relevant information across multiple data types
6+
7+
Background:
8+
Given a functioning api
9+
And the system has valid contact, well, and spring records in the database
10+
11+
@positive @happy_path
12+
Scenario: Retrieve mixed search results
13+
When the user searches for "<search_term>"
14+
Then the system should return a 200 status code
15+
And the system should return a response in JSON format
16+
And the response should include results grouped by:
17+
| Contacts | Wells | Springs |
18+
And each result should include a label, group, and properties
19+
20+
@positive @happy_path
21+
Scenario: Retrieve contact results
22+
When the user searches for "<contact_search_term>"
23+
Then the system should return a 200 status code
24+
And the response should include a "Contacts" group
25+
And each contact result should include:
26+
#| TODO: use correct field name syntax |
27+
| id | first_name | last_name | email | phone | address | associated_things |
28+
29+
@positive @happy_path
30+
Scenario: Retrieve well results
31+
When the user searches for "<well_search_term>"
32+
Then the system should return a 200 status code
33+
And the response should include a "Wells" group
34+
And each well result should include:
35+
#| TODO: use correct field name syntax |
36+
| thing_type | id | name | alternate site name | contact first name | contact last name | contact id | county |
37+
38+
@positive @happy_path
39+
Scenario: Retrieve spring results
40+
When the user searches for "<spring_search_term>"
41+
Then the system should return a 200 status code
42+
And the response should include a "Springs" group
43+
And each spring result should include:
44+
| thing_type | id |
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Created by jakeross at 10/21/25
2+
@backend @BDMS-199
3+
Feature: Retrieve sensor notes
4+
As a user
5+
I want to retrieve sensor notes for a given well name
6+
So that I can view important information about the well's deployed sensors
7+
Background:
8+
Given a functioning api
9+
And the system has valid well and location data in the database
10+
11+
# @positive @happy_path
12+
# Scenario: Request sensor notes for an existing well
13+
# When the user requests the sensor for well 1
14+
# Then the system should return a 200 status code
15+
# And the system should return a response in JSON format
16+
# And the response should include notes
17+
# And the notes should be a non-empty string
18+
19+
@positive
20+
Scenario: Request sensor notes by sensor ID
21+
When the user requests the sensor with ID 1
22+
Then the system should return a 200 status code
23+
And the system should return a response in JSON format
24+
And the response should include notes
25+
And the notes should be a non-empty string
26+
27+
@negative
28+
Scenario: Request sensor notes for a non-existing sensor ID
29+
When the user requests the sensor with ID 9999
30+
Then the system should return a 404 status code
31+
And the system should return a response in JSON format
32+
And the response should include an error message indicating the sensor was not found
33+
34+
# @negative @sad_path
35+
# Scenario: Request sensor notes for a non-existing well
36+
# When the user requests the sensor for well 9999
37+
# Then the system should return a 404 status code
38+
# And the system should return a response in JSON format
39+
# And the response should include an error message indicating the well was not found

tests/features/steps/well-notes.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,17 @@ def step_impl(context):
4949
)
5050
def step_impl(context):
5151
data = context.response.json()
52-
assert (
53-
"well_construction_notes" in data
54-
), "Response does not include construction notes"
55-
assert data["well_construction_notes"] is not None, "Construction notes is null"
56-
context.notes["construction"] = data["well_construction_notes"]
52+
assert "construction_notes" in data, "Response does not include construction notes"
53+
assert data["construction_notes"] is not None, "Construction notes is null"
54+
context.notes["construction"] = data["construction_notes"]
5755

5856

5957
@then("the response should include general well notes (catch all notes field)")
6058
def step_impl(context):
6159
data = context.response.json()
62-
assert "notes" in data, "Response does not include notes"
63-
assert data["notes"] is not None, "Notes is null"
64-
context.notes["general"] = data["notes"]
60+
assert "general_notes" in data, "Response does not include notes"
61+
assert data["general_notes"] is not None, "Notes is null"
62+
context.notes["general"] = data["general_notes"]
6563

6664

6765
@then(

0 commit comments

Comments
 (0)