Add in library filter for chapters
This commit is contained in:
@@ -39,6 +39,7 @@ import suwayomi.tachidesk.graphql.server.primitives.maybeSwap
|
||||
import suwayomi.tachidesk.graphql.types.ChapterNodeList
|
||||
import suwayomi.tachidesk.graphql.types.ChapterType
|
||||
import suwayomi.tachidesk.manga.model.table.ChapterTable
|
||||
import suwayomi.tachidesk.manga.model.table.MangaTable
|
||||
import java.util.concurrent.CompletableFuture
|
||||
|
||||
/**
|
||||
@@ -164,6 +165,7 @@ class ChapterQuery {
|
||||
val fetchedAt: LongFilter? = null,
|
||||
val isDownloaded: BooleanFilter? = null,
|
||||
val pageCount: IntFilter? = null,
|
||||
val inLibrary: BooleanFilter? = null,
|
||||
override val and: List<ChapterFilter>? = null,
|
||||
override val or: List<ChapterFilter>? = null,
|
||||
override val not: ChapterFilter? = null
|
||||
@@ -188,6 +190,8 @@ class ChapterQuery {
|
||||
andFilterWithCompare(ChapterTable.pageCount, pageCount)
|
||||
)
|
||||
}
|
||||
|
||||
fun getLibraryOp() = andFilterWithCompare(MangaTable.inLibrary, inLibrary)
|
||||
}
|
||||
|
||||
fun chapters(
|
||||
@@ -204,6 +208,14 @@ class ChapterQuery {
|
||||
val queryResults = transaction {
|
||||
val res = ChapterTable.selectAll()
|
||||
|
||||
val libraryOp = filter?.getLibraryOp()
|
||||
if (libraryOp != null) {
|
||||
res.adjustColumnSet {
|
||||
innerJoin(MangaTable)
|
||||
}
|
||||
res.andWhere { libraryOp }
|
||||
}
|
||||
|
||||
res.applyOps(condition, filter)
|
||||
|
||||
if (orderBy != null || (last != null || before != null)) {
|
||||
|
||||
@@ -15,7 +15,6 @@ import org.jetbrains.exposed.sql.SortOrder
|
||||
import org.jetbrains.exposed.sql.SqlExpressionBuilder.greater
|
||||
import org.jetbrains.exposed.sql.SqlExpressionBuilder.less
|
||||
import org.jetbrains.exposed.sql.andWhere
|
||||
import org.jetbrains.exposed.sql.select
|
||||
import org.jetbrains.exposed.sql.selectAll
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import suwayomi.tachidesk.graphql.queries.filter.BooleanFilter
|
||||
@@ -224,12 +223,14 @@ class MangaQuery {
|
||||
offset: Int? = null
|
||||
): MangaNodeList {
|
||||
val queryResults = transaction {
|
||||
var res = MangaTable.selectAll()
|
||||
val res = MangaTable.selectAll()
|
||||
|
||||
val categoryOp = filter?.getCategoryOp()
|
||||
if (categoryOp != null) {
|
||||
res = MangaTable.innerJoin(CategoryMangaTable)
|
||||
.select { categoryOp }
|
||||
res.adjustColumnSet {
|
||||
innerJoin(CategoryMangaTable)
|
||||
}
|
||||
res.andWhere { categoryOp }
|
||||
}
|
||||
|
||||
res.applyOps(condition, filter)
|
||||
|
||||
Reference in New Issue
Block a user