Cleaning up traks
This commit is contained in:
@@ -61,12 +61,12 @@ dependencies {
|
|||||||
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.6'
|
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.6'
|
||||||
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.6'
|
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.6'
|
||||||
|
|
||||||
implementation 'androidx.core:core-ktx:1.4.0-alpha01'
|
implementation 'androidx.core:core-ktx:1.5.0-alpha01'
|
||||||
implementation 'androidx.appcompat:appcompat:1.3.0-alpha01'
|
implementation 'androidx.appcompat:appcompat:1.3.0-alpha01'
|
||||||
implementation 'androidx.activity:activity-ktx:1.2.0-alpha05'
|
implementation 'androidx.activity:activity-ktx:1.2.0-alpha06'
|
||||||
implementation 'androidx.fragment:fragment-ktx:1.3.0-alpha05'
|
implementation 'androidx.fragment:fragment-ktx:1.3.0-alpha06'
|
||||||
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.0-alpha03'
|
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.0-alpha04'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta6'
|
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta7'
|
||||||
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-rc01'
|
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-rc01'
|
||||||
implementation 'androidx.recyclerview:recyclerview:1.2.0-alpha03'
|
implementation 'androidx.recyclerview:recyclerview:1.2.0-alpha03'
|
||||||
implementation 'androidx.viewpager2:viewpager2:1.1.0-alpha01'
|
implementation 'androidx.viewpager2:viewpager2:1.1.0-alpha01'
|
||||||
|
|||||||
@@ -19,4 +19,7 @@ interface TrackLogsDao {
|
|||||||
|
|
||||||
@Query("DELETE FROM track_logs WHERE manga_id = :mangaId")
|
@Query("DELETE FROM track_logs WHERE manga_id = :mangaId")
|
||||||
suspend fun removeAll(mangaId: Long)
|
suspend fun removeAll(mangaId: Long)
|
||||||
|
|
||||||
|
@Query("DELETE FROM track_logs WHERE manga_id NOT IN (SELECT manga_id FROM tracks)")
|
||||||
|
suspend fun cleanup()
|
||||||
}
|
}
|
||||||
@@ -25,11 +25,13 @@ abstract class TracksDao {
|
|||||||
@Query("DELETE FROM tracks WHERE manga_id = :mangaId")
|
@Query("DELETE FROM tracks WHERE manga_id = :mangaId")
|
||||||
abstract suspend fun delete(mangaId: Long)
|
abstract suspend fun delete(mangaId: Long)
|
||||||
|
|
||||||
|
@Query("DELETE FROM tracks WHERE manga_id NOT IN (SELECT manga_id FROM history UNION SELECT manga_id FROM favourites)")
|
||||||
|
abstract suspend fun cleanup()
|
||||||
|
|
||||||
@Transaction
|
@Transaction
|
||||||
open suspend fun upsert(entity: TrackEntity) {
|
open suspend fun upsert(entity: TrackEntity) {
|
||||||
if (update(entity) == 0) {
|
if (update(entity) == 0) {
|
||||||
insert(entity)
|
insert(entity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -44,6 +44,13 @@ class TrackingRepository : KoinComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun cleanup() {
|
||||||
|
db.withTransaction {
|
||||||
|
db.tracksDao.cleanup()
|
||||||
|
db.trackLogsDao.cleanup()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
suspend fun storeTrackResult(
|
suspend fun storeTrackResult(
|
||||||
mangaId: Long,
|
mangaId: Long,
|
||||||
knownChaptersCount: Int,
|
knownChaptersCount: Int,
|
||||||
|
|||||||
@@ -118,6 +118,7 @@ class TrackWorker(context: Context, workerParams: WorkerParameters) :
|
|||||||
}
|
}
|
||||||
success++
|
success++
|
||||||
}
|
}
|
||||||
|
repo.cleanup()
|
||||||
if (success == 0) {
|
if (success == 0) {
|
||||||
Result.retry()
|
Result.retry()
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ buildscript {
|
|||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:4.1.0-alpha10'
|
classpath 'com.android.tools.build:gradle:4.2.0-alpha02'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
|
|||||||
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
|||||||
#Sat May 30 09:45:56 EEST 2020
|
#Sat Jun 20 11:05:53 EEST 2020
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-milestone-1-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
|
||||||
|
|||||||
Reference in New Issue
Block a user