38 lines
1.4 KiB
Kotlin
38 lines
1.4 KiB
Kotlin
|
|
package exh.debug
|
||
|
|
|
||
|
|
import com.pushtorefresh.storio.sqlite.queries.RawQuery
|
||
|
|
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||
|
|
import eu.kanade.tachiyomi.data.database.tables.MangaTable
|
||
|
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||
|
|
import uy.kohesive.injekt.injectLazy
|
||
|
|
|
||
|
|
object DebugFunctions {
|
||
|
|
val db: DatabaseHelper by injectLazy()
|
||
|
|
val prefs: PreferencesHelper by injectLazy()
|
||
|
|
|
||
|
|
fun addAllMangaInDatabaseToLibrary() {
|
||
|
|
db.inTransaction {
|
||
|
|
db.lowLevel().executeSQL(RawQuery.builder()
|
||
|
|
.query("""
|
||
|
|
UPDATE ${MangaTable.TABLE}
|
||
|
|
SET ${MangaTable.COL_FAVORITE} = 1
|
||
|
|
""".trimIndent())
|
||
|
|
.affectsTables(MangaTable.TABLE)
|
||
|
|
.build())
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
fun countMangaInDatabaseInLibrary() = db.getMangas().executeAsBlocking().count { it.favorite }
|
||
|
|
|
||
|
|
fun countMangaInDatabaseNotInLibrary() = db.getMangas().executeAsBlocking().count { !it.favorite }
|
||
|
|
|
||
|
|
fun countMangaInDatabase() = db.getMangas().executeAsBlocking().size
|
||
|
|
|
||
|
|
fun countMetadataInDatabase() = db.getSearchMetadata().executeAsBlocking().size
|
||
|
|
|
||
|
|
fun countMangaInLibraryWithMissingMetadata() = db.getMangas().executeAsBlocking().count {
|
||
|
|
it.favorite && db.getSearchMetadataForManga(it.id!!).executeAsBlocking() == null
|
||
|
|
}
|
||
|
|
|
||
|
|
fun clearSavedSearches() = prefs.eh_savedSearches().set("")
|
||
|
|
}
|