mirror of
https://github.com/mihonapp/mihon.git
synced 2025-01-30 20:04:56 +01:00
clean un-relevant errors from DB on every updates
This commit is contained in:
parent
ff25910820
commit
5d95c72e03
@ -110,6 +110,8 @@ class LibraryUpdateJob(private val context: Context, workerParams: WorkerParamet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deleteLibraryUpdateErrors.cleanUnrelevantMangaErrors()
|
||||||
|
|
||||||
setForegroundSafely()
|
setForegroundSafely()
|
||||||
|
|
||||||
libraryPreferences.lastUpdatedTimestamp().set(Instant.now().toEpochMilli())
|
libraryPreferences.lastUpdatedTimestamp().set(Instant.now().toEpochMilli())
|
||||||
|
@ -45,6 +45,12 @@ class LibraryUpdateErrorRepositoryImpl(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override suspend fun cleanUnrelevantMangaErrors() {
|
||||||
|
return handler.await {
|
||||||
|
libraryUpdateErrorQueries.cleanUnrelevantMangaErrors()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override suspend fun upsert(libraryUpdateError: LibraryUpdateError) {
|
override suspend fun upsert(libraryUpdateError: LibraryUpdateError) {
|
||||||
return handler.await(inTransaction = true) {
|
return handler.await(inTransaction = true) {
|
||||||
libraryUpdateErrorQueries.upsert(
|
libraryUpdateErrorQueries.upsert(
|
||||||
|
@ -30,3 +30,12 @@ WHERE _id = :_id;
|
|||||||
deleteMangaError:
|
deleteMangaError:
|
||||||
DELETE FROM libraryUpdateError
|
DELETE FROM libraryUpdateError
|
||||||
WHERE manga_id = :mangaId;
|
WHERE manga_id = :mangaId;
|
||||||
|
|
||||||
|
cleanUnrelevantMangaErrors:
|
||||||
|
DELETE FROM libraryUpdateError
|
||||||
|
WHERE NOT EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM mangas
|
||||||
|
WHERE libraryUpdateError.manga_id = mangas._id
|
||||||
|
AND mangas.favorite == 1
|
||||||
|
);
|
@ -39,8 +39,18 @@ class DeleteLibraryUpdateErrors(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun cleanUnrelevantMangaErrors() = withNonCancellableContext {
|
||||||
|
try {
|
||||||
|
libraryUpdateErrorRepository.cleanUnrelevantMangaErrors()
|
||||||
|
Result.Success
|
||||||
|
} catch (e: Exception) {
|
||||||
|
logcat(LogPriority.ERROR, e)
|
||||||
|
return@withNonCancellableContext Result.InternalError(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sealed class Result {
|
sealed class Result {
|
||||||
object Success : Result()
|
data object Success : Result()
|
||||||
data class InternalError(val error: Throwable) : Result()
|
data class InternalError(val error: Throwable) : Result()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,8 @@ interface LibraryUpdateErrorRepository {
|
|||||||
|
|
||||||
suspend fun deleteMangaError(mangaId: Long)
|
suspend fun deleteMangaError(mangaId: Long)
|
||||||
|
|
||||||
|
suspend fun cleanUnrelevantMangaErrors()
|
||||||
|
|
||||||
suspend fun upsert(libraryUpdateError: LibraryUpdateError)
|
suspend fun upsert(libraryUpdateError: LibraryUpdateError)
|
||||||
|
|
||||||
suspend fun insert(libraryUpdateError: LibraryUpdateError)
|
suspend fun insert(libraryUpdateError: LibraryUpdateError)
|
||||||
|
@ -21,7 +21,7 @@ class DeleteLibraryUpdateErrorMessages(
|
|||||||
}
|
}
|
||||||
|
|
||||||
sealed class Result {
|
sealed class Result {
|
||||||
object Success : Result()
|
data object Success : Result()
|
||||||
data class InternalError(val error: Throwable) : Result()
|
data class InternalError(val error: Throwable) : Result()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user