rfcx / rfcx-api

Core, Media/Assets and MQTT APIs
https://api.rfcx.org/docs/
Apache License 2.0
0 stars 0 forks source link

Bug: Calling `GET /detections/summary` before `GET /detections` results in not all attributes being applied #600

Closed grindarius closed 6 months ago

grindarius commented 6 months ago

Describe the bug This bug happens when the frontend API calls GET /detections/summary before GET /detections. You will not get any other attributes from other tables.

To Reproduce Steps to reproduce the behavior:

  1. call GET /detections/summary (please give authorization header for it to work)
  2. call GET /detections with the same query parameters as the previous API call.
  3. The detections API will not return key classification in all of the objects inside of the response array.

Expected behavior All keys should work as normal.

Additional context I think the problem is here https://github.com/rfcx/rfcx-api/blob/3489d50603eb4f336741cdbf3030f50dd210611d/core/detections/dao/index.js#L276-L280

The opts.include in-place modification somehow makes it applies those changes to other functions as well. I will make those use a map instead so we get a new object every time we call. Also I will be adding checks to the GET /detections test suite as well.