stumpapp / stump

A free and open source comics, manga and digital book server with OPDS support (WIP)
https://stumpapp.dev
MIT License
863 stars 34 forks source link

Advanced filtering #183

Closed aaronleopold closed 6 months ago

aaronleopold commented 9 months ago

Recently filtering, in general, has been massively improved. I don't think it needs to be extended further for the existing GET requests, and honestly not sure it could be, but I would like to be able to someday POST to something like /media/search or /media/filter that supports VERY complex query options (AND'ing, OR'ing, NOT'ing, etc). This will probably require some VERY interesting serialization hacks. Offhand, I would imagine something like:

#[serde(untagged)]
enum Filter<T> {
    Equals(T)
    Not { not: T },
    Contains { contains: T },
    Excludes { excludes: T },
}

#[serde(untagged)]
enum FilterGroup<T> {
    And {
        and: Vec<Filter<T>>,
    },
    Or {
        or: Vec<Filter<T>>,
    },
    Not { not: Vec<Filter<T>> },
}

So an example POST body might look like:

/media/filter

{
    "and": [
        {
           "title": "Must equal this value"
        },
        {
            "status": {
                "not": "Must NOT be this value"
            }
        }
    ]
}

I'm just spitballing here though 😄. This would heavily support the development of https://github.com/stumpapp/stump/issues/174

Extra context

aaronleopold commented 6 months ago

I have started roughing out details for this in al/smart-lists. Once the WIP implementation is more robust and worked through, I'll implement smart lists (https://github.com/stumpapp/stump/issues/174) before exposing the more advanced filtering to the current UI sections for filtering.