QutEcoacoustics / baw-server

The acoustic workbench server for storing and managing ecoacoustic data. Manages the structure and audio data. Provides an API for clients access.
Apache License 2.0
9 stars 4 forks source link

Add support for projection and filtering for custom fields in associations #689

Open hudson-newey opened 2 days ago

hudson-newey commented 2 days ago

When filtering audio events by their audio recording associated model recorded_end_date, the server throws an internal server error.

Doing some digging around, I found that the guard for build_custom_calculated_field might be rejecting the custom_fields2 key https://github.com/QutEcoacoustics/baw-server/blob/master/app/modules/filter/custom_field.rb#L28-L40

And processing the key as if it was database-backed

https://github.com/QutEcoacoustics/baw-server/blob/master/app/modules/filter/build.rb#L322-L323

Example payload

// POST https://api.staging.ecosounds.org/audio_events/filter

{
  "filter": {
    "audio_recordings.recorded_end_date": {
      "greater_than": "2024-10-02T00:00:00.000+10:00"
    }
  }
}
atruskie commented 1 day ago

scope: Add support for projection and filtering for custom fields in associations