Skip to content

feat: add transducer observation handling and improve database initialization#235

Merged
jirhiker merged 17 commits into
stagingfrom
jir-fix-transducer
Nov 13, 2025
Merged

feat: add transducer observation handling and improve database initialization#235
jirhiker merged 17 commits into
stagingfrom
jir-fix-transducer

Conversation

@jirhiker

@jirhiker jirhiker commented Nov 6, 2025

Copy link
Copy Markdown
Member

Why

This PR addresses the following problem / context:

  • Use bullet points here

How

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

  • Use bullet points here

Notes

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

  • Use bullet points here

@codecov-commenter

codecov-commenter commented Nov 6, 2025

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Patch % Lines
services/observation_helper.py 0.00% 5 Missing ⚠️
api/observation.py 50.00% 1 Missing ⚠️
core/app.py 50.00% 1 Missing ⚠️
Files with missing lines Coverage Δ
core/initializers.py 87.65% <100.00%> (+1.63%) ⬆️
tests/test_observation.py 94.13% <100.00%> (-1.70%) ⬇️
api/observation.py 96.00% <50.00%> (-4.00%) ⬇️
core/app.py 29.62% <50.00%> (-0.50%) ⬇️
services/observation_helper.py 76.66% <0.00%> (-15.38%) ⬇️

... and 16 files with indirect coverage changes

Comment thread tests/features/steps/transducer.py
Comment thread tests/features/steps/transducer.py Outdated
Comment on lines +55 to +57
if thing_id:
simple_get_by_id(session, Thing, thing_id)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This raises a 404 error if thing_id does not exist, but since thing_id is a query parameter if there are no observations for that thing (one of the reasons could be that the thing_id does not exist), it should just return an empty list.

I think that 404 errors should only be returned for path parameters since the full path is a resource.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is not how the feature file is written. https://github.com/DataIntegrationGroup/OcotilloBDD/blob/main/features/backend/transducer-data-response.feature

When the user requests transducer data for a non-existing well
      Then the system should return a 404 status code

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remaining faithful to the feature file, it seems like making thing_id a path parameter is the best approach. In the case of using a query parameter, I don't think it makes sense to get an empty list if the thing_id is invalid.

I think internal int ids should be path parameters
get observation/transducer-groundwater-level/123

Human-readable identifiers like name, pointid, site-name, etc, should be query parameters. e.g.

get observation/transducer-groundwater-level?thing.name == 'WL-001'
but we don't have a need for this functionality at this time.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote up a discussion about this a while ago to record my thoughts: https://github.com/orgs/DataIntegrationGroup/discussions/14

The empty list vs 404 error came up when @TylerAdamMartinez and I were working on AMP API and the water level entry form a while ago. I can look more into the appropriate response when a user supplies an erroneous query parameter.

I also agree that path parameter ids should pertain to that table

@jirhiker

Copy link
Copy Markdown
Member Author

@jacob-a-brown can we get this approved and merged

@jacob-a-brown

jacob-a-brown commented Nov 13, 2025

Copy link
Copy Markdown
Contributor

@jirhiker

jirhiker commented Nov 13, 2025

Copy link
Copy Markdown
Member Author

I'm good with that pattern for other endpoints. I removed the functionality of using thing_id as a query parameter for transducer observations for this iteration as there isn't a use case for it yet

@jacob-a-brown

jacob-a-brown commented Nov 13, 2025

Copy link
Copy Markdown
Contributor

I missed that, I was still reading the thing_id as a query parameter. Does it make sense to have thing_id be the path parameter for a table for which it is not the ID? I thought that the IDs for path parameters pertained to the table itself, not related tables

@jirhiker

Copy link
Copy Markdown
Member Author

It's a good point. It's not something that matters in practice but for consistency I will change back to a query parameter

@jirhiker jirhiker merged commit 1310375 into staging Nov 13, 2025
6 checks passed
@jirhiker jirhiker deleted the jir-fix-transducer branch November 13, 2025 16:58
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.

3 participants