mirror of
https://github.com/Suwayomi/Tachidesk.git
synced 2025-12-10 14:52:05 +01:00
Add private to trackrecords filter (#1468)
* Add private to trackrecords filter * Remove sourceMapping from base * Format
This commit is contained in:
@@ -256,6 +256,7 @@ class TrackQuery {
|
||||
SCORE(TrackRecordTable.score),
|
||||
START_DATE(TrackRecordTable.startDate),
|
||||
FINISH_DATE(TrackRecordTable.finishDate),
|
||||
PRIVATE(TrackRecordTable.private),
|
||||
;
|
||||
|
||||
override fun greater(cursor: Cursor): Op<Boolean> =
|
||||
@@ -270,6 +271,7 @@ class TrackQuery {
|
||||
SCORE -> greaterNotUnique(TrackRecordTable.score, TrackRecordTable.id, cursor, String::toDouble)
|
||||
START_DATE -> greaterNotUnique(TrackRecordTable.startDate, TrackRecordTable.id, cursor, String::toLong)
|
||||
FINISH_DATE -> greaterNotUnique(TrackRecordTable.finishDate, TrackRecordTable.id, cursor, String::toLong)
|
||||
PRIVATE -> greaterNotUnique(TrackRecordTable.private, TrackRecordTable.id, cursor, String::toBoolean)
|
||||
}
|
||||
|
||||
override fun less(cursor: Cursor): Op<Boolean> =
|
||||
@@ -284,6 +286,7 @@ class TrackQuery {
|
||||
SCORE -> lessNotUnique(TrackRecordTable.score, TrackRecordTable.id, cursor, String::toDouble)
|
||||
START_DATE -> lessNotUnique(TrackRecordTable.startDate, TrackRecordTable.id, cursor, String::toLong)
|
||||
FINISH_DATE -> lessNotUnique(TrackRecordTable.finishDate, TrackRecordTable.id, cursor, String::toLong)
|
||||
PRIVATE -> lessNotUnique(TrackRecordTable.private, TrackRecordTable.id, cursor, String::toBoolean)
|
||||
}
|
||||
|
||||
override fun asCursor(type: TrackRecordType): Cursor {
|
||||
@@ -299,6 +302,7 @@ class TrackQuery {
|
||||
SCORE -> type.id.toString() + "-" + type.score
|
||||
START_DATE -> type.id.toString() + "-" + type.startDate
|
||||
FINISH_DATE -> type.id.toString() + "-" + type.finishDate
|
||||
PRIVATE -> type.id.toString() + "-" + type.private
|
||||
}
|
||||
return Cursor(value)
|
||||
}
|
||||
@@ -323,6 +327,7 @@ class TrackQuery {
|
||||
val remoteUrl: String? = null,
|
||||
val startDate: Long? = null,
|
||||
val finishDate: Long? = null,
|
||||
val private: Boolean? = null,
|
||||
) : HasGetOp {
|
||||
override fun getOp(): Op<Boolean>? {
|
||||
val opAnd = OpAnd()
|
||||
@@ -339,6 +344,7 @@ class TrackQuery {
|
||||
opAnd.eq(remoteUrl, TrackRecordTable.remoteUrl)
|
||||
opAnd.eq(startDate, TrackRecordTable.startDate)
|
||||
opAnd.eq(finishDate, TrackRecordTable.finishDate)
|
||||
opAnd.eq(private, TrackRecordTable.private)
|
||||
|
||||
return opAnd.op
|
||||
}
|
||||
@@ -358,6 +364,7 @@ class TrackQuery {
|
||||
val remoteUrl: StringFilter? = null,
|
||||
val startDate: LongFilter? = null,
|
||||
val finishDate: LongFilter? = null,
|
||||
val private: BooleanFilter? = null,
|
||||
override val and: List<TrackRecordFilter>? = null,
|
||||
override val or: List<TrackRecordFilter>? = null,
|
||||
override val not: TrackRecordFilter? = null,
|
||||
@@ -377,6 +384,7 @@ class TrackQuery {
|
||||
andFilterWithCompareString(TrackRecordTable.remoteUrl, remoteUrl),
|
||||
andFilterWithCompare(TrackRecordTable.startDate, startDate),
|
||||
andFilterWithCompare(TrackRecordTable.finishDate, finishDate),
|
||||
andFilterWithCompare(TrackRecordTable.private, private),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,5 @@ package suwayomi.tachidesk.manga.impl.backup.proto
|
||||
import kotlinx.serialization.protobuf.ProtoBuf
|
||||
|
||||
open class ProtoBackupBase {
|
||||
var sourceMapping: Map<Long, String> = emptyMap()
|
||||
|
||||
val parser = ProtoBuf
|
||||
}
|
||||
|
||||
@@ -65,22 +65,18 @@ import kotlin.math.max
|
||||
import kotlin.time.Duration.Companion.milliseconds
|
||||
import suwayomi.tachidesk.manga.impl.track.Track as Tracker
|
||||
|
||||
enum class RestoreMode {
|
||||
NEW,
|
||||
EXISTING,
|
||||
}
|
||||
|
||||
object ProtoBackupImport : ProtoBackupBase() {
|
||||
private val scope = CoroutineScope(SupervisorJob() + Dispatchers.Default)
|
||||
|
||||
private val logger = KotlinLogging.logger {}
|
||||
|
||||
private var restoreAmount = 0
|
||||
|
||||
private val errors = mutableListOf<Pair<Date, String>>()
|
||||
|
||||
private val backupMutex = Mutex()
|
||||
|
||||
enum class RestoreMode {
|
||||
NEW,
|
||||
EXISTING,
|
||||
}
|
||||
|
||||
sealed class BackupRestoreState {
|
||||
data object Idle : BackupRestoreState()
|
||||
|
||||
@@ -199,7 +195,7 @@ object ProtoBackupImport : ProtoBackupBase() {
|
||||
val restoreMeta = 1
|
||||
val restoreSettings = 1
|
||||
val getRestoreAmount = { size: Int -> size + restoreCategories + restoreMeta + restoreSettings }
|
||||
restoreAmount = getRestoreAmount(backup.backupManga.size)
|
||||
val restoreAmount = getRestoreAmount(backup.backupManga.size)
|
||||
|
||||
updateRestoreState(id, BackupRestoreState.RestoringCategories(restoreCategories, restoreAmount))
|
||||
|
||||
@@ -219,7 +215,9 @@ object ProtoBackupImport : ProtoBackupBase() {
|
||||
restoreServerSettings(backup.serverSettings)
|
||||
|
||||
// Store source mapping for error messages
|
||||
sourceMapping = backup.getSourceMap()
|
||||
val sourceMapping = backup.getSourceMap()
|
||||
|
||||
val errors = mutableListOf<Pair<Date, String>>()
|
||||
|
||||
// Restore individual manga
|
||||
backup.backupManga.forEachIndexed { index, manga ->
|
||||
@@ -235,6 +233,8 @@ object ProtoBackupImport : ProtoBackupBase() {
|
||||
restoreManga(
|
||||
backupManga = manga,
|
||||
categoryMapping = categoryMapping,
|
||||
sourceMapping = sourceMapping,
|
||||
errors = errors,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -277,6 +277,8 @@ object ProtoBackupImport : ProtoBackupBase() {
|
||||
private fun restoreManga(
|
||||
backupManga: BackupManga,
|
||||
categoryMapping: Map<Int, Int>,
|
||||
sourceMapping: Map<Long, String>,
|
||||
errors: MutableList<Pair<Date, String>>,
|
||||
) {
|
||||
val chapters = backupManga.chapters
|
||||
val categories = backupManga.categories
|
||||
|
||||
Reference in New Issue
Block a user