Use sqldelight in migration (#7331)

* Use sqldelight in migration

* Some more changes

Co-Authored-By: Ivan Iskandar <12537387+ivaniskandar@users.noreply.github.com>

* Review Changes

* Review changes 2

* Review Changes 3

* Review Changes 4

Co-authored-by: Ivan Iskandar <12537387+ivaniskandar@users.noreply.github.com>
This commit is contained in:
AntsyLich
2022-06-22 03:27:55 +06:00
committed by GitHub
parent c2520bff12
commit e3b1053c03
23 changed files with 374 additions and 155 deletions

View File

@@ -0,0 +1,20 @@
package eu.kanade.domain.track.interactor
import eu.kanade.domain.track.model.Track
import eu.kanade.domain.track.repository.TrackRepository
import eu.kanade.tachiyomi.util.system.logcat
import logcat.LogPriority
class GetTracks(
private val trackRepository: TrackRepository,
) {
suspend fun await(mangaId: Long): List<Track> {
return try {
trackRepository.getTracksByMangaId(mangaId)
} catch (e: Exception) {
logcat(LogPriority.ERROR, e)
emptyList()
}
}
}

View File

@@ -0,0 +1,19 @@
package eu.kanade.domain.track.interactor
import eu.kanade.domain.track.model.Track
import eu.kanade.domain.track.repository.TrackRepository
import eu.kanade.tachiyomi.util.system.logcat
import logcat.LogPriority
class InsertTrack(
private val trackRepository: TrackRepository,
) {
suspend fun awaitAll(tracks: List<Track>) {
try {
trackRepository.insertAll(tracks)
} catch (e: Exception) {
logcat(LogPriority.ERROR, e)
}
}
}

View File

@@ -0,0 +1,27 @@
package eu.kanade.domain.track.model
data class Track(
val id: Long,
val mangaId: Long,
val syncId: Long,
val remoteId: Long,
val libraryId: Long?,
val title: String,
val lastChapterRead: Double,
val totalChapters: Long,
val status: Long,
val score: Float,
val remoteUrl: String,
val startDate: Long,
val finishDate: Long,
) {
fun copyPersonalFrom(other: Track): Track {
return this.copy(
lastChapterRead = other.lastChapterRead,
score = other.score,
status = other.status,
startDate = other.startDate,
finishDate = other.finishDate,
)
}
}

View File

@@ -0,0 +1,10 @@
package eu.kanade.domain.track.repository
import eu.kanade.domain.track.model.Track
interface TrackRepository {
suspend fun getTracksByMangaId(mangaId: Long): List<Track>
suspend fun insertAll(tracks: List<Track>)
}