Open hudson-newey opened 10 months ago
In addition to this issue, we should improve errors emitted by annotation imports
e.g. uploading a file with an audio_recording_id
that you do not have access to
PUT https://api.staging.ecosounds.org/audio_event_imports/116
audio_recording_id,start_time_seconds,end_time_seconds,low_frequency_hertz,high_frequency_hertz,tag
1,123,456,100,500,Bird
returns a HTTP status 401
with the response body:
This should instead by emitted in the imported audio event's error
property coupled with the other file import errors
Additional bug: there seems to be a race condition if we upload multiple files (in multiple requests) in quick succession.
e.g.
Additional bug: there are no errors for audio recordings that do not exist. It just returns an "internal server error" (not in the error object array)
As previously discussed, we should make some changes to the annotation upload api
Improved returned errors
Errors should change from
to
Splitting annotation read and write annotation imports into separate routes
At the moment we have two models
import
andaudio_event_import
.Both are accessed from the
/audio_event_imports/:id
route, but use separate models for reading and writing (audio_event_import
for GET and PATCH, andimport
for formData PUT)To make the event import API more in line with restful practices, we should split both models over two separate routes.
Move imported annotation files to the paginated route
Since some event imports such as analysis jobs will produce tens of thousands of imported files, this would place a lot of strain on the API.
We should therefore create a new paginated route to get files from
audio_event_import
modelsIn short, we should remove sub-models and move them to their own models, return an array of id's so that we can use client-side associations to fetch sub-models
Edit: We may want to move
imported_events
onaudio_event_import
model to return an array of id's instead