mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-18 02:03:33 -05:00
Add logic to only update specific categories (#520)
Makes it possible to only update specific categories. In case a manga is in an excluded category it will be excluded even if it is also in an included category.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package suwayomi.tachidesk.manga.model.dataclass
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonValue
|
||||
|
||||
/*
|
||||
* Copyright (C) Contributors to the Suwayomi project
|
||||
*
|
||||
@@ -7,11 +9,20 @@ package suwayomi.tachidesk.manga.model.dataclass
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
enum class IncludeInUpdate(@JsonValue val value: Int) {
|
||||
EXCLUDE(0), INCLUDE(1), UNSET(-1);
|
||||
|
||||
companion object {
|
||||
fun fromValue(value: Int) = IncludeInUpdate.values().find { it.value == value } ?: UNSET
|
||||
}
|
||||
}
|
||||
|
||||
data class CategoryDataClass(
|
||||
val id: Int,
|
||||
val order: Int,
|
||||
val name: String,
|
||||
val default: Boolean,
|
||||
val size: Int,
|
||||
val includeInUpdate: IncludeInUpdate,
|
||||
val meta: Map<String, String> = emptyMap()
|
||||
)
|
||||
|
||||
@@ -11,11 +11,13 @@ import org.jetbrains.exposed.dao.id.IntIdTable
|
||||
import org.jetbrains.exposed.sql.ResultRow
|
||||
import suwayomi.tachidesk.manga.impl.Category
|
||||
import suwayomi.tachidesk.manga.model.dataclass.CategoryDataClass
|
||||
import suwayomi.tachidesk.manga.model.dataclass.IncludeInUpdate
|
||||
|
||||
object CategoryTable : IntIdTable() {
|
||||
val name = varchar("name", 64)
|
||||
val order = integer("order").default(0)
|
||||
val isDefault = bool("is_default").default(false)
|
||||
val includeInUpdate = integer("include_in_update").default(IncludeInUpdate.UNSET.value)
|
||||
}
|
||||
|
||||
fun CategoryTable.toDataClass(categoryEntry: ResultRow) = CategoryDataClass(
|
||||
@@ -24,5 +26,6 @@ fun CategoryTable.toDataClass(categoryEntry: ResultRow) = CategoryDataClass(
|
||||
categoryEntry[name],
|
||||
categoryEntry[isDefault],
|
||||
Category.getCategorySize(categoryEntry[id].value),
|
||||
IncludeInUpdate.fromValue(categoryEntry[includeInUpdate]),
|
||||
Category.getCategoryMetaMap(categoryEntry[id].value)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user