Description
To support the generation of field forms and ensure continuity of site-specific historical knowledge, the legacy SiteNotes field from the legacy WaterLevels table needs to be systematically mapped and transferred into the new database structure. Currently, these notes exist only in legacy CSV/table formats and are not accessible to the field form generation logic or the new API schemas.
Context
This work is required to preserve historical context for field technicians and to ensure that legacy "Site Notes" are visible when preparing for field events.
The handling of empty states ensures that downstream clients (like field form generators) can reliably iterate over the site_notes array without checking for null values.
Proposed Changes
- Lexicon Update: Add
Site Notes (legacy) to the note_type category in the lexicon to categorize these migrated records correctly.
- Data Trasfer Logic:
- Update the
WaterLevelTransferer to extract unique SiteNotes per PointID.
- Prepend the date (YYYY-MM-DD: ) to the note content to preserve historical context.
- Implement filtering to exclude missing (NaN), blank, or whitespace-only records.
- Deduplicate notes that have identical content and occur on the same day for the same PointID.
- Map valid notes to the Notes table with:
target_table: 'thing'
target_id: Linked thing_id
note_type: 'Site Notes (legacy)'
- Database Model Extension: Add a
site_notes property to the Thing model in db/thing.py to facilitate easy retrieval of these categorized notes.
- API Schema Update: Include
site_notes in the BaseThingResponse (and inherited WellResponse) in schemas/thing.py so they are exposed via the /things endpoints.
Acceptance Criteria
Notes
The legacy SiteNotes field could benefit from additional note categorization (e.g there are SiteNotes records whose context would be better categorized as note_type = Sampling Procedure or note_type = Access). This will be treated as a separate issue to be addressed at a later time.
Description
To support the generation of field forms and ensure continuity of site-specific historical knowledge, the legacy
SiteNotesfield from the legacyWaterLevelstable needs to be systematically mapped and transferred into the new database structure. Currently, these notes exist only in legacy CSV/table formats and are not accessible to the field form generation logic or the new API schemas.Context
This work is required to preserve historical context for field technicians and to ensure that legacy "Site Notes" are visible when preparing for field events.
The handling of empty states ensures that downstream clients (like field form generators) can reliably iterate over the
site_notesarray without checking for null values.Proposed Changes
Site Notes (legacy)to thenote_typecategory in the lexicon to categorize these migrated records correctly.WaterLevelTransfererto extract uniqueSiteNotesperPointID.target_table:'thing'target_id: Linkedthing_idnote_type:'Site Notes (legacy)'site_notesproperty to theThingmodel indb/thing.pyto facilitate easy retrieval of these categorized notes.site_notesin theBaseThingResponse(and inheritedWellResponse) inschemas/thing.pyso they are exposed via the/thingsendpoints.Acceptance Criteria
Site Notes (legacy)exists in core/lexicon.json.WaterLevelstransfer process successfully createsNotesrecords for non-blank legacy notes.NULLlegacy notes from the source CSV do not result in new records in theNotestable.site_notesarray containing the migrated content.Thing(i.e., source data was missing or blank), the API MUST return a valid empty list[]for thesite_notesfield, rather thannullor omitting the field entirely.Notes
The legacy
SiteNotesfield could benefit from additional note categorization (e.g there areSiteNotesrecords whose context would be better categorized asnote_type=Sampling Procedureornote_type=Access). This will be treated as a separate issue to be addressed at a later time.