mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-04 03:14:40 -05:00
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.ChapterNodeList
|
||||||
import suwayomi.tachidesk.graphql.types.ChapterType
|
import suwayomi.tachidesk.graphql.types.ChapterType
|
||||||
import suwayomi.tachidesk.manga.model.table.ChapterTable
|
import suwayomi.tachidesk.manga.model.table.ChapterTable
|
||||||
|
import suwayomi.tachidesk.manga.model.table.MangaTable
|
||||||
import java.util.concurrent.CompletableFuture
|
import java.util.concurrent.CompletableFuture
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -164,6 +165,7 @@ class ChapterQuery {
|
|||||||
val fetchedAt: LongFilter? = null,
|
val fetchedAt: LongFilter? = null,
|
||||||
val isDownloaded: BooleanFilter? = null,
|
val isDownloaded: BooleanFilter? = null,
|
||||||
val pageCount: IntFilter? = null,
|
val pageCount: IntFilter? = null,
|
||||||
|
val inLibrary: BooleanFilter? = null,
|
||||||
override val and: List<ChapterFilter>? = null,
|
override val and: List<ChapterFilter>? = null,
|
||||||
override val or: List<ChapterFilter>? = null,
|
override val or: List<ChapterFilter>? = null,
|
||||||
override val not: ChapterFilter? = null
|
override val not: ChapterFilter? = null
|
||||||
@@ -188,6 +190,8 @@ class ChapterQuery {
|
|||||||
andFilterWithCompare(ChapterTable.pageCount, pageCount)
|
andFilterWithCompare(ChapterTable.pageCount, pageCount)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getLibraryOp() = andFilterWithCompare(MangaTable.inLibrary, inLibrary)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun chapters(
|
fun chapters(
|
||||||
@@ -204,6 +208,14 @@ class ChapterQuery {
|
|||||||
val queryResults = transaction {
|
val queryResults = transaction {
|
||||||
val res = ChapterTable.selectAll()
|
val res = ChapterTable.selectAll()
|
||||||
|
|
||||||
|
val libraryOp = filter?.getLibraryOp()
|
||||||
|
if (libraryOp != null) {
|
||||||
|
res.adjustColumnSet {
|
||||||
|
innerJoin(MangaTable)
|
||||||
|
}
|
||||||
|
res.andWhere { libraryOp }
|
||||||
|
}
|
||||||
|
|
||||||
res.applyOps(condition, filter)
|
res.applyOps(condition, filter)
|
||||||
|
|
||||||
if (orderBy != null || (last != null || before != null)) {
|
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.greater
|
||||||
import org.jetbrains.exposed.sql.SqlExpressionBuilder.less
|
import org.jetbrains.exposed.sql.SqlExpressionBuilder.less
|
||||||
import org.jetbrains.exposed.sql.andWhere
|
import org.jetbrains.exposed.sql.andWhere
|
||||||
import org.jetbrains.exposed.sql.select
|
|
||||||
import org.jetbrains.exposed.sql.selectAll
|
import org.jetbrains.exposed.sql.selectAll
|
||||||
import org.jetbrains.exposed.sql.transactions.transaction
|
import org.jetbrains.exposed.sql.transactions.transaction
|
||||||
import suwayomi.tachidesk.graphql.queries.filter.BooleanFilter
|
import suwayomi.tachidesk.graphql.queries.filter.BooleanFilter
|
||||||
@@ -224,12 +223,14 @@ class MangaQuery {
|
|||||||
offset: Int? = null
|
offset: Int? = null
|
||||||
): MangaNodeList {
|
): MangaNodeList {
|
||||||
val queryResults = transaction {
|
val queryResults = transaction {
|
||||||
var res = MangaTable.selectAll()
|
val res = MangaTable.selectAll()
|
||||||
|
|
||||||
val categoryOp = filter?.getCategoryOp()
|
val categoryOp = filter?.getCategoryOp()
|
||||||
if (categoryOp != null) {
|
if (categoryOp != null) {
|
||||||
res = MangaTable.innerJoin(CategoryMangaTable)
|
res.adjustColumnSet {
|
||||||
.select { categoryOp }
|
innerJoin(CategoryMangaTable)
|
||||||
|
}
|
||||||
|
res.andWhere { categoryOp }
|
||||||
}
|
}
|
||||||
|
|
||||||
res.applyOps(condition, filter)
|
res.applyOps(condition, filter)
|
||||||
|
|||||||
Reference in New Issue
Block a user