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.
This commit is contained in:
arkon
2021-12-17 12:29:54 -05:00
parent c16206d816
commit 65062b4bcb
13 changed files with 3 additions and 169 deletions

View File

@@ -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()