소스 검색

Remove library update order setting

This doesn't make sense to have if the intention is to have reasonably sized global updates. Opting to remove it to remove complexity instead.
arkon 3 년 전
부모
커밋
65062b4bcb

+ 0 - 3
app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/MangaTypeMapping.kt

@@ -22,7 +22,6 @@ import eu.kanade.tachiyomi.data.database.tables.MangaTable.COL_GENRE
 import eu.kanade.tachiyomi.data.database.tables.MangaTable.COL_ID
 import eu.kanade.tachiyomi.data.database.tables.MangaTable.COL_INITIALIZED
 import eu.kanade.tachiyomi.data.database.tables.MangaTable.COL_LAST_UPDATE
-import eu.kanade.tachiyomi.data.database.tables.MangaTable.COL_NEXT_UPDATE
 import eu.kanade.tachiyomi.data.database.tables.MangaTable.COL_SOURCE
 import eu.kanade.tachiyomi.data.database.tables.MangaTable.COL_STATUS
 import eu.kanade.tachiyomi.data.database.tables.MangaTable.COL_THUMBNAIL_URL
@@ -63,7 +62,6 @@ class MangaPutResolver : DefaultPutResolver<Manga>() {
             COL_THUMBNAIL_URL to obj.thumbnail_url,
             COL_FAVORITE to obj.favorite,
             COL_LAST_UPDATE to obj.last_update,
-            COL_NEXT_UPDATE to obj.next_update,
             COL_INITIALIZED to obj.initialized,
             COL_VIEWER to obj.viewer_flags,
             COL_CHAPTER_FLAGS to obj.chapter_flags,
@@ -86,7 +84,6 @@ interface BaseMangaGetResolver {
         thumbnail_url = cursor.getString(cursor.getColumnIndex(COL_THUMBNAIL_URL))
         favorite = cursor.getInt(cursor.getColumnIndex(COL_FAVORITE)) == 1
         last_update = cursor.getLong(cursor.getColumnIndex(COL_LAST_UPDATE))
-        next_update = cursor.getLong(cursor.getColumnIndex(COL_NEXT_UPDATE))
         initialized = cursor.getInt(cursor.getColumnIndex(COL_INITIALIZED)) == 1
         viewer_flags = cursor.getInt(cursor.getColumnIndex(COL_VIEWER))
         chapter_flags = cursor.getInt(cursor.getColumnIndex(COL_CHAPTER_FLAGS))

+ 0 - 3
app/src/main/java/eu/kanade/tachiyomi/data/database/models/Manga.kt

@@ -16,9 +16,6 @@ interface Manga : SManga {
     // last time the chapter list changed in any way
     var last_update: Long
 
-    // predicted next update time based on latest (by date) 4 chapters' deltas
-    var next_update: Long
-
     var date_added: Long
 
     var viewer_flags: Int

+ 0 - 2
app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaImpl.kt

@@ -26,8 +26,6 @@ open class MangaImpl : Manga {
 
     override var last_update: Long = 0
 
-    override var next_update: Long = 0
-
     override var date_added: Long = 0
 
     override var initialized: Boolean = false

+ 0 - 6
app/src/main/java/eu/kanade/tachiyomi/data/database/queries/MangaQueries.kt

@@ -14,7 +14,6 @@ import eu.kanade.tachiyomi.data.database.resolvers.MangaCoverLastModifiedPutReso
 import eu.kanade.tachiyomi.data.database.resolvers.MangaFavoritePutResolver
 import eu.kanade.tachiyomi.data.database.resolvers.MangaFlagsPutResolver
 import eu.kanade.tachiyomi.data.database.resolvers.MangaLastUpdatedPutResolver
-import eu.kanade.tachiyomi.data.database.resolvers.MangaNextUpdatedPutResolver
 import eu.kanade.tachiyomi.data.database.resolvers.MangaTitlePutResolver
 import eu.kanade.tachiyomi.data.database.resolvers.SourceIdMangaCountGetResolver
 import eu.kanade.tachiyomi.data.database.tables.CategoryTable
@@ -108,11 +107,6 @@ interface MangaQueries : DbProvider {
         .withPutResolver(MangaFlagsPutResolver(MangaTable.COL_VIEWER, Manga::viewer_flags))
         .prepare()
 
-    fun updateNextUpdated(manga: Manga) = db.put()
-        .`object`(manga)
-        .withPutResolver(MangaNextUpdatedPutResolver())
-        .prepare()
-
     fun updateLastUpdated(manga: Manga) = db.put()
         .`object`(manga)
         .withPutResolver(MangaLastUpdatedPutResolver())

+ 0 - 31
app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaNextUpdatedPutResolver.kt

@@ -1,31 +0,0 @@
-package eu.kanade.tachiyomi.data.database.resolvers
-
-import androidx.core.content.contentValuesOf
-import com.pushtorefresh.storio.sqlite.StorIOSQLite
-import com.pushtorefresh.storio.sqlite.operations.put.PutResolver
-import com.pushtorefresh.storio.sqlite.operations.put.PutResult
-import com.pushtorefresh.storio.sqlite.queries.UpdateQuery
-import eu.kanade.tachiyomi.data.database.inTransactionReturn
-import eu.kanade.tachiyomi.data.database.models.Manga
-import eu.kanade.tachiyomi.data.database.tables.MangaTable
-
-class MangaNextUpdatedPutResolver : PutResolver<Manga>() {
-
-    override fun performPut(db: StorIOSQLite, manga: Manga) = db.inTransactionReturn {
-        val updateQuery = mapToUpdateQuery(manga)
-        val contentValues = mapToContentValues(manga)
-
-        val numberOfRowsUpdated = db.lowLevel().update(updateQuery, contentValues)
-        PutResult.newUpdateResult(numberOfRowsUpdated, updateQuery.table())
-    }
-
-    fun mapToUpdateQuery(manga: Manga) = UpdateQuery.builder()
-        .table(MangaTable.TABLE)
-        .where("${MangaTable.COL_ID} = ?")
-        .whereArgs(manga.id)
-        .build()
-
-    fun mapToContentValues(manga: Manga) = contentValuesOf(
-        MangaTable.COL_NEXT_UPDATE to manga.next_update
-    )
-}

+ 1 - 0
app/src/main/java/eu/kanade/tachiyomi/data/database/tables/MangaTable.kt

@@ -28,6 +28,7 @@ object MangaTable {
 
     const val COL_LAST_UPDATE = "last_update"
 
+    // Not actually used anymore
     const val COL_NEXT_UPDATE = "next_update"
 
     const val COL_DATE_ADDED = "date_added"

+ 0 - 58
app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateRanker.kt

@@ -1,58 +0,0 @@
-package eu.kanade.tachiyomi.data.library
-
-import eu.kanade.tachiyomi.data.database.models.Manga
-import java.util.Collections
-import kotlin.math.abs
-
-/**
- * This class will provide various functions to rank manga to efficiently schedule manga to update.
- */
-object LibraryUpdateRanker {
-
-    val rankingScheme = listOf(
-        (this::lexicographicRanking)(),
-        (this::latestFirstRanking)(),
-        (this::nextFirstRanking)()
-    )
-
-    /**
-     * Provides a total ordering over all the Mangas.
-     *
-     * Orders the manga based on the distance between the next expected update and now.
-     * The comparator is reversed, placing the smallest (and thus closest to updating now) first.
-     */
-    fun nextFirstRanking(): Comparator<Manga> {
-        val time = System.currentTimeMillis()
-        return Collections.reverseOrder(
-            Comparator { mangaFirst: Manga,
-                mangaSecond: Manga ->
-                compareValues(abs(mangaSecond.next_update - time), abs(mangaFirst.next_update - time))
-            }
-        )
-    }
-
-    /**
-     * Provides a total ordering over all the [Manga]s.
-     *
-     * Assumption: An active [Manga] mActive is expected to have been last updated after an
-     * inactive [Manga] mInactive.
-     *
-     * Using this insight, function returns a Comparator for which mActive appears before mInactive.
-     * @return a Comparator that ranks manga based on relevance.
-     */
-    private fun latestFirstRanking(): Comparator<Manga> =
-        Comparator { first: Manga, second: Manga ->
-            compareValues(second.last_update, first.last_update)
-        }
-
-    /**
-     * Provides a total ordering over all the [Manga]s.
-     *
-     * Order the manga lexicographically.
-     * @return a Comparator that ranks manga lexicographically based on the title.
-     */
-    private fun lexicographicRanking(): Comparator<Manga> =
-        Comparator { first: Manga, second: Manga ->
-            compareValues(first.title, second.title)
-        }
-}

+ 1 - 3
app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt

@@ -17,7 +17,6 @@ import eu.kanade.tachiyomi.data.database.models.Manga
 import eu.kanade.tachiyomi.data.database.models.toMangaInfo
 import eu.kanade.tachiyomi.data.download.DownloadManager
 import eu.kanade.tachiyomi.data.download.DownloadService
-import eu.kanade.tachiyomi.data.library.LibraryUpdateRanker.rankingScheme
 import eu.kanade.tachiyomi.data.library.LibraryUpdateService.Companion.start
 import eu.kanade.tachiyomi.data.notification.Notifications
 import eu.kanade.tachiyomi.data.preference.MANGA_FULLY_READ
@@ -271,10 +270,9 @@ class LibraryUpdateService(
             }
         }
 
-        val selectedScheme = preferences.libraryUpdatePrioritization().get()
         mangaToUpdate = listToUpdate
             .distinctBy { it.id }
-            .sortedWith(rankingScheme[selectedScheme])
+            .sortedBy { it.title }
 
         // Warn when excessively checking a single source
         val maxUpdatesFromSource = mangaToUpdate

+ 0 - 2
app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt

@@ -137,8 +137,6 @@ object PreferenceKeys {
     const val libraryUpdateCategories = "library_update_categories"
     const val libraryUpdateCategoriesExclude = "library_update_categories_exclude"
 
-    const val libraryUpdatePrioritization = "library_update_prioritization"
-
     const val downloadedOnly = "pref_downloaded_only"
 
     const val filterDownloaded = "pref_filter_library_downloaded"

+ 0 - 2
app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt

@@ -242,8 +242,6 @@ class PreferencesHelper(val context: Context) {
     fun libraryUpdateCategories() = flowPrefs.getStringSet(Keys.libraryUpdateCategories, emptySet())
     fun libraryUpdateCategoriesExclude() = flowPrefs.getStringSet(Keys.libraryUpdateCategoriesExclude, emptySet())
 
-    fun libraryUpdatePrioritization() = flowPrefs.getInt(Keys.libraryUpdatePrioritization, 0)
-
     fun libraryDisplayMode() = flowPrefs.getEnum(Keys.libraryDisplayMode, DisplayModeSetting.COMPACT_GRID)
 
     fun downloadBadge() = flowPrefs.getBoolean(Keys.downloadBadge, false)

+ 0 - 28
app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt

@@ -270,34 +270,6 @@ class SettingsLibraryController : SettingsController() {
                     .onEach { updateSummary() }
                     .launchIn(viewScope)
             }
-            intListPreference {
-                key = Keys.libraryUpdatePrioritization
-                titleRes = R.string.pref_library_update_prioritization
-
-                visibleIfGlobalUpdateEnabled()
-
-                // The following array lines up with the list rankingScheme in:
-                // ../../data/library/LibraryUpdateRanker.kt
-                val priorities = arrayOf(
-                    Pair("0", R.string.action_sort_alpha),
-                    Pair("1", R.string.action_sort_last_checked),
-                    Pair("2", R.string.action_sort_next_updated)
-                )
-                val defaultPriority = priorities[0]
-
-                entriesRes = priorities.map { it.second }.toTypedArray()
-                entryValues = priorities.map { it.first }.toTypedArray()
-                defaultValue = defaultPriority.first
-
-                val selectedPriority = priorities.find { it.first.toInt() == preferences.libraryUpdatePrioritization().get() }
-                summaryRes = selectedPriority?.second ?: defaultPriority.second
-                onChange { newValue ->
-                    summaryRes = priorities.find {
-                        it.first == (newValue as String)
-                    }?.second ?: defaultPriority.second
-                    true
-                }
-            }
             switchPreference {
                 key = Keys.autoUpdateMetadata
                 titleRes = R.string.pref_library_update_refresh_metadata

+ 1 - 29
app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterSourceSync.kt

@@ -97,24 +97,10 @@ fun syncChaptersWithSource(
 
     // Return if there's nothing to add, delete or change, avoiding unnecessary db transactions.
     if (toAdd.isEmpty() && toDelete.isEmpty() && toChange.isEmpty()) {
-        val topChapters = dbChapters.sortedByDescending { it.date_upload }.take(4)
-        val newestDate = topChapters.getOrNull(0)?.date_upload ?: 0L
-
-        // Recalculate update rate if unset and enough chapters are present
-        if (manga.next_update == 0L && topChapters.size > 1) {
-            var delta = 0L
-            for (i in 0 until topChapters.size - 1) {
-                delta += (topChapters[i].date_upload - topChapters[i + 1].date_upload)
-            }
-            delta /= topChapters.size - 1
-            manga.next_update = newestDate + delta
-            db.updateNextUpdated(manga).executeAsBlocking()
-        }
-
         return Pair(emptyList(), emptyList())
     }
 
-    val readded = mutableListOf<Chapter>()
+    val readded = mutableSetOf<Chapter>()
 
     db.inTransaction {
         val deletedChapterNumbers = TreeSet<Float>()
@@ -155,20 +141,6 @@ fun syncChaptersWithSource(
             db.insertChapters(toChange).executeAsBlocking()
         }
 
-        val topChapters = db.getChapters(manga).executeAsBlocking()
-            .sortedByDescending { it.date_upload }
-            .take(4)
-        // Recalculate next update since chapters were changed
-        if (topChapters.size > 1) {
-            var delta = 0L
-            for (i in 0 until topChapters.size - 1) {
-                delta += (topChapters[i].date_upload - topChapters[i + 1].date_upload)
-            }
-            delta /= topChapters.size - 1
-            manga.next_update = topChapters[0].date_upload + delta
-            db.updateNextUpdated(manga).executeAsBlocking()
-        }
-
         // Fix order in source.
         db.fixChaptersSourceOrder(sourceChapters).executeAsBlocking()
 

+ 0 - 2
app/src/main/res/values/strings.xml

@@ -44,7 +44,6 @@
     <string name="action_sort_total">Total chapters</string>
     <string name="action_sort_last_read">Last read</string>
     <string name="action_sort_last_checked">Last checked</string>
-    <string name="action_sort_next_updated">Next expected update</string>
     <string name="action_sort_latest_chapter">Latest chapter</string>
     <string name="action_sort_chapter_fetch_date">Date fetched</string>
     <string name="action_sort_date_added">Date added</string>
@@ -216,7 +215,6 @@
     <string name="update_48hour">Every 2 days</string>
     <string name="update_72hour">Every 3 days</string>
     <string name="update_weekly">Weekly</string>
-    <string name="pref_library_update_prioritization">Update order</string>
     <string name="pref_library_update_restriction">Device restrictions</string>
     <string name="connected_to_wifi">Only on Wi-Fi</string>
     <string name="charging">Charging</string>