mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-12 23:34:34 -05:00
Feature/gql simpilify filtering for multiple values (#960)
* Remove code duplication
* Remove unnecessary functions
* Simplify filtering for multiple values in queries
Makes it easier to filter for multiple values at ones without having to nest filters with multiple "and".
e.g.
```gql
query MyQuery {
mangas(
filter: {genre: {includesInsensitive: "action"}, and: {genre: {includesInsensitive: "adventure"}, and: { ... }}}
) {
nodes {
id
}
}
}
```
can be simplified to
```gql
query MyQuery {
mangas(
filter: {genre: {includesInsensitive: ["action", "adventure", ...]}}
) {
nodes {
id
}
}
}
```
* Add filter for matching "any" value in list
Makes it easier to filter for entries that match any value without having to nest filters with multiple "or".
e.g.
```gql
query MyQuery {
mangas(
filter: {genre: {includesInsensitiveAny: ["action", "adventure", ...]}}
) {
nodes {
id
}
}
}
```
instead of
```gql
query MyQuery {
mangas(
filter: {genre: {includesInsensitive: "action", or: {genre: includesInsensitive: "adventure", or: {...}}}}
) {
nodes {
id
}
}
}
```
* Add util function to apply "andWhere/All/Any"
This commit is contained in:
@@ -126,14 +126,14 @@ class MangaQuery {
|
||||
opAnd.eq(artist, MangaTable.artist)
|
||||
opAnd.eq(author, MangaTable.author)
|
||||
opAnd.eq(description, MangaTable.description)
|
||||
genre?.forEach { opAnd.like("%$it%", MangaTable.genre) }
|
||||
opAnd.andWhereAll(genre) { MangaTable.genre like "%$it%" }
|
||||
opAnd.eq(status?.value, MangaTable.status)
|
||||
opAnd.eq(inLibrary, MangaTable.inLibrary)
|
||||
opAnd.eq(inLibraryAt, MangaTable.inLibraryAt)
|
||||
opAnd.eq(realUrl, MangaTable.realUrl)
|
||||
opAnd.eq(lastFetchedAt, MangaTable.lastFetchedAt)
|
||||
opAnd.eq(chaptersLastFetchedAt, MangaTable.chaptersLastFetchedAt)
|
||||
opAnd.inList(categoryIds, CategoryMangaTable.category)
|
||||
opAnd.andWhere(categoryIds) { CategoryMangaTable.category inList it }
|
||||
|
||||
return opAnd.op
|
||||
}
|
||||
@@ -143,7 +143,11 @@ class MangaQuery {
|
||||
override val isNull: Boolean? = null,
|
||||
override val equalTo: MangaStatus? = null,
|
||||
override val notEqualTo: MangaStatus? = null,
|
||||
override val notEqualToAll: List<MangaStatus>? = null,
|
||||
override val notEqualToAny: List<MangaStatus>? = null,
|
||||
override val distinctFrom: MangaStatus? = null,
|
||||
override val distinctFromAll: List<MangaStatus>? = null,
|
||||
override val distinctFromAny: List<MangaStatus>? = null,
|
||||
override val notDistinctFrom: MangaStatus? = null,
|
||||
override val `in`: List<MangaStatus>? = null,
|
||||
override val notIn: List<MangaStatus>? = null,
|
||||
@@ -156,7 +160,11 @@ class MangaQuery {
|
||||
IntFilter(
|
||||
equalTo = equalTo?.value,
|
||||
notEqualTo = notEqualTo?.value,
|
||||
notEqualToAll = notEqualToAll?.map { it.value },
|
||||
notEqualToAny = notEqualToAny?.map { it.value },
|
||||
distinctFrom = distinctFrom?.value,
|
||||
distinctFromAll = distinctFromAll?.map { it.value },
|
||||
distinctFromAny = distinctFromAny?.map { it.value },
|
||||
notDistinctFrom = notDistinctFrom?.value,
|
||||
`in` = `in`?.map { it.value },
|
||||
notIn = notIn?.map { it.value },
|
||||
|
||||
Reference in New Issue
Block a user