mirror of
https://github.com/Suwayomi/Tachidesk.git
synced 2025-12-11 07:12:06 +01:00
Fix/graphql mangas query genre based filtering (#713)
* Filter mangas based on each genre of the genre condition Genres are stored as a comma separated string in the database. Thus, unless the correct string was passed in the condition, no manga would match the condition. * Query mangas based on genre filter
This commit is contained in:
@@ -122,7 +122,7 @@ class MangaQuery {
|
|||||||
opAnd.eq(artist, MangaTable.artist)
|
opAnd.eq(artist, MangaTable.artist)
|
||||||
opAnd.eq(author, MangaTable.author)
|
opAnd.eq(author, MangaTable.author)
|
||||||
opAnd.eq(description, MangaTable.description)
|
opAnd.eq(description, MangaTable.description)
|
||||||
opAnd.eq(genre?.joinToString(), MangaTable.genre)
|
genre?.forEach { opAnd.like("%$it%", MangaTable.genre) }
|
||||||
opAnd.eq(status?.value, MangaTable.status)
|
opAnd.eq(status?.value, MangaTable.status)
|
||||||
opAnd.eq(inLibrary, MangaTable.inLibrary)
|
opAnd.eq(inLibrary, MangaTable.inLibrary)
|
||||||
opAnd.eq(inLibraryAt, MangaTable.inLibraryAt)
|
opAnd.eq(inLibraryAt, MangaTable.inLibraryAt)
|
||||||
@@ -172,7 +172,7 @@ class MangaQuery {
|
|||||||
val artist: StringFilter? = null,
|
val artist: StringFilter? = null,
|
||||||
val author: StringFilter? = null,
|
val author: StringFilter? = null,
|
||||||
val description: StringFilter? = null,
|
val description: StringFilter? = null,
|
||||||
// val genre: List<String>? = null, // todo
|
val genre: StringFilter? = null,
|
||||||
val status: MangaStatusFilter? = null,
|
val status: MangaStatusFilter? = null,
|
||||||
val inLibrary: BooleanFilter? = null,
|
val inLibrary: BooleanFilter? = null,
|
||||||
val inLibraryAt: LongFilter? = null,
|
val inLibraryAt: LongFilter? = null,
|
||||||
@@ -194,6 +194,7 @@ class MangaQuery {
|
|||||||
andFilterWithCompareString(MangaTable.artist, artist),
|
andFilterWithCompareString(MangaTable.artist, artist),
|
||||||
andFilterWithCompareString(MangaTable.author, author),
|
andFilterWithCompareString(MangaTable.author, author),
|
||||||
andFilterWithCompareString(MangaTable.description, description),
|
andFilterWithCompareString(MangaTable.description, description),
|
||||||
|
andFilterWithCompareString(MangaTable.genre, genre),
|
||||||
andFilterWithCompare(MangaTable.status, status?.asIntFilter()),
|
andFilterWithCompare(MangaTable.status, status?.asIntFilter()),
|
||||||
andFilterWithCompare(MangaTable.inLibrary, inLibrary),
|
andFilterWithCompare(MangaTable.inLibrary, inLibrary),
|
||||||
andFilterWithCompare(MangaTable.inLibraryAt, inLibraryAt),
|
andFilterWithCompare(MangaTable.inLibraryAt, inLibraryAt),
|
||||||
|
|||||||
@@ -391,6 +391,11 @@ class OpAnd(var op: Op<Boolean>? = null) {
|
|||||||
value: T?,
|
value: T?,
|
||||||
column: Column<EntityID<T>>,
|
column: Column<EntityID<T>>,
|
||||||
) = andWhere(value) { column eq it }
|
) = andWhere(value) { column eq it }
|
||||||
|
|
||||||
|
fun like(
|
||||||
|
value: String?,
|
||||||
|
column: Column<String?>,
|
||||||
|
) = andWhere(value) { column like it }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <T : Comparable<T>> andFilterWithCompare(
|
fun <T : Comparable<T>> andFilterWithCompare(
|
||||||
|
|||||||
Reference in New Issue
Block a user