Cleanup data layer (#7450)

This commit is contained in:
Andreas
2022-07-03 21:48:13 +02:00
committed by GitHub
parent 68697e59d7
commit 069bd90c0f
5 changed files with 39 additions and 99 deletions

View File

@@ -41,39 +41,28 @@ class ChapterRepositoryImpl(
}
override suspend fun update(chapterUpdate: ChapterUpdate) {
handler.await {
chaptersQueries.update(
chapterUpdate.mangaId,
chapterUpdate.url,
chapterUpdate.name,
chapterUpdate.scanlator,
chapterUpdate.read?.toLong(),
chapterUpdate.bookmark?.toLong(),
chapterUpdate.lastPageRead,
chapterUpdate.chapterNumber?.toDouble(),
chapterUpdate.sourceOrder,
chapterUpdate.dateFetch,
chapterUpdate.dateUpload,
chapterId = chapterUpdate.id,
)
}
partialUpdate(chapterUpdate)
}
override suspend fun updateAll(chapterUpdates: List<ChapterUpdate>) {
partialUpdate(*chapterUpdates.toTypedArray())
}
private suspend fun partialUpdate(vararg chapterUpdates: ChapterUpdate) {
handler.await(inTransaction = true) {
chapterUpdates.forEach { chapterUpdate ->
chaptersQueries.update(
chapterUpdate.mangaId,
chapterUpdate.url,
chapterUpdate.name,
chapterUpdate.scanlator,
chapterUpdate.read?.toLong(),
chapterUpdate.bookmark?.toLong(),
chapterUpdate.lastPageRead,
chapterUpdate.chapterNumber?.toDouble(),
chapterUpdate.sourceOrder,
chapterUpdate.dateFetch,
chapterUpdate.dateUpload,
mangaId = chapterUpdate.mangaId,
url = chapterUpdate.url,
name = chapterUpdate.name,
scanlator = chapterUpdate.scanlator,
read = chapterUpdate.read?.toLong(),
bookmark = chapterUpdate.bookmark?.toLong(),
lastPageRead = chapterUpdate.lastPageRead,
chapterNumber = chapterUpdate.chapterNumber?.toDouble(),
sourceOrder = chapterUpdate.sourceOrder,
dateFetch = chapterUpdate.dateFetch,
dateUpload = chapterUpdate.dateUpload,
chapterId = chapterUpdate.id,
)
}