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

Support filtering nested associated models #690

Open hudson-newey opened 1 week ago

hudson-newey commented 1 week ago

A really amazing feature of the API is that we can filter by properties on associated models

// POST /audio_events/filter
{
    "filters": {
        "audio_recordings.id": {
            "in": [1, 2, 3, 4]
        }
    }
}

However, nesting these associations does not work

e.g.

// POST /audio_events/filter
{
    "filters": {
        "audio_recordings.projects.id": {
            "in": [1, 2, 3, 4]
        }
    }
}

We should add support for nested associations in filter conditions like the example above so that filter conditions can support more complex queries such as filtering by project id on an audio event (through the associated audio event model).