Count early, late and backdated releases when predicting next update

This commit is contained in:
AntsyLich
2026-10-11 21:33:35 +06:00
parent fc20410ceb
commit ba44815254
6 changed files with 558 additions and 217 deletions
@@ -226,11 +226,18 @@ class SyncChaptersWithSource(
updated = updatedChapters,
)
val excludedScanlators = getExcludedScanlators.await(manga.id).toHashSet()
// A first fetch lists the back catalogue, and chapters coming back under a deleted number were out already
val foundRelease = dbChapters.isNotEmpty() &&
toAdd.any { chapter ->
chapter.scanlator !in excludedScanlators &&
!(chapter.isRecognizedNumber && chapter.chapterNumber in deletedChapterNumbers)
}
// Set this manga as updated since chapters were changed
// Note that last_update actually represents last time the chapter list changed at all
updateManga.awaitUpdateFetchIntervalAndLastUpdate(manga, timeZone, now, fetchWindow)
val excludedScanlators = getExcludedScanlators.await(manga.id).toHashSet()
updateManga.awaitUpdateFetchIntervalAndLastUpdate(manga, timeZone, now, fetchWindow, foundRelease)
return added.filterNot { it.url in changedOrDuplicateReadUrls || it.scanlator in excludedScanlators }
}
@@ -44,9 +44,10 @@ class UpdateManga(
timeZone: TimeZone,
dateTime: LocalDateTime,
window: ClosedRange<Instant>?,
foundRelease: Boolean,
): Boolean {
return mangaRepository.update(
fetchInterval.withFetchInterval(manga, dateTime, timeZone, window).apply {
fetchInterval.withFetchInterval(manga, dateTime, timeZone, window, foundRelease).apply {
lastUpdate = Clock.System.now()
},
)