feat: add transducer observation handling and improve database initialization#235
Conversation
Codecov Report❌ Patch coverage is
|
| if thing_id: | ||
| simple_get_by_id(session, Thing, thing_id) | ||
|
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
…data retrieval logic
…ations and improve query handling
…ment variables from tests.yml
|
@jacob-a-brown can we get this approved and merged |
|
Would you be okay to change the feature file to return an empty list when a https://softwareengineering.stackexchange.com/questions/203492/when-to-use-http-status-code-404-in-an-api |
|
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 |
|
I missed that, I was still reading the |
|
It's a good point. It's not something that matters in practice but for consistency I will change back to a query parameter |
…thing_id and add related test assertions
Why
This PR addresses the following problem / context:
How
Implementation summary - the following was changed / added / removed:
Notes
Any special considerations, workarounds, or follow-up work to note?