Add support for configuring which categories are downloaded automatically (#832)

* Rename IncludeInUpdate class to IncludeOrExclude

Signed-off-by: Chance Zibolski <chance.zibolski@gmail.com>

* Add support for configuring which categories are downloaded automatically

If a manga has no configured categories, behavior remains the same and
the automatic download functionality will download new chapters without
consulting the category includeInDownload configuration.

Signed-off-by: Chance Zibolski <chance.zibolski@gmail.com>

---------

Signed-off-by: Chance Zibolski <chance.zibolski@gmail.com>
This commit is contained in:
Chance Zibolski
2024-01-20 16:41:47 -08:00
committed by GitHub
parent f224918f33
commit 57d5bc6480
10 changed files with 114 additions and 26 deletions

View File

@@ -9,7 +9,7 @@ import com.fasterxml.jackson.annotation.JsonValue
* 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(
enum class IncludeOrExclude(
@JsonValue val value: Int,
) {
EXCLUDE(0),
@@ -18,7 +18,7 @@ enum class IncludeInUpdate(
;
companion object {
fun fromValue(value: Int) = IncludeInUpdate.values().find { it.value == value } ?: UNSET
fun fromValue(value: Int) = IncludeOrExclude.values().find { it.value == value } ?: UNSET
}
}
@@ -28,6 +28,7 @@ data class CategoryDataClass(
val name: String,
val default: Boolean,
val size: Int,
val includeInUpdate: IncludeInUpdate,
val includeInUpdate: IncludeOrExclude,
val includeInDownload: IncludeOrExclude,
val meta: Map<String, String> = emptyMap(),
)

View File

@@ -11,13 +11,14 @@ 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
import suwayomi.tachidesk.manga.model.dataclass.IncludeOrExclude
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)
val includeInUpdate = integer("include_in_update").default(IncludeOrExclude.UNSET.value)
val includeInDownload = integer("include_in_download").default(IncludeOrExclude.UNSET.value)
}
fun CategoryTable.toDataClass(categoryEntry: ResultRow) =
@@ -27,6 +28,7 @@ fun CategoryTable.toDataClass(categoryEntry: ResultRow) =
categoryEntry[name],
categoryEntry[isDefault],
Category.getCategorySize(categoryEntry[id].value),
IncludeInUpdate.fromValue(categoryEntry[includeInUpdate]),
IncludeOrExclude.fromValue(categoryEntry[includeInUpdate]),
IncludeOrExclude.fromValue(categoryEntry[includeInDownload]),
Category.getCategoryMetaMap(categoryEntry[id].value),
)