Limit updates to 250 most recent chapters
Still limits to things within the past 3 months though. Closes #9554 (cherry picked from commit 4c65c2311e09bf5dcb77327c415a6fddd12123c5) # Conflicts: # data/src/main/java/tachiyomi/data/updates/UpdatesRepositoryImpl.kt # domain/src/main/java/tachiyomi/domain/updates/interactor/GetUpdates.kt
This commit is contained in:
@@ -90,6 +90,6 @@ class AndroidDatabaseHandler(
|
||||
// SY -->
|
||||
fun getLibraryQuery(condition: String = "M.favorite = 1") = LibraryQuery(driver, condition)
|
||||
|
||||
fun getUpdatesQuery(after: Long) = UpdatesQuery(driver, after)
|
||||
fun getUpdatesQuery(after: Long, limit: Long) = UpdatesQuery(driver, after, limit)
|
||||
// SY <--
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ private val mapper = { cursor: SqlCursor ->
|
||||
)
|
||||
}
|
||||
|
||||
class UpdatesQuery(val driver: SqlDriver, val after: Long) : Query<UpdatesView>(copyOnWriteList(), mapper) {
|
||||
class UpdatesQuery(val driver: SqlDriver, val after: Long, val limit: Long) : Query<UpdatesView>(copyOnWriteList(), mapper) {
|
||||
override fun execute(): SqlCursor {
|
||||
return driver.executeQuery(
|
||||
null,
|
||||
@@ -79,11 +79,13 @@ class UpdatesQuery(val driver: SqlDriver, val after: Long) : Query<UpdatesView>(
|
||||
WHERE favorite = 1 AND source = $MERGED_SOURCE_ID
|
||||
AND date_fetch > date_added
|
||||
AND dateUpload > :after
|
||||
ORDER BY datefetch DESC;
|
||||
ORDER BY datefetch DESC
|
||||
LIMIT :limit;
|
||||
""".trimIndent(),
|
||||
1,
|
||||
2,
|
||||
binders = {
|
||||
bindLong(1, after)
|
||||
bindLong(2, limit)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -21,11 +21,11 @@ class UpdatesRepositoryImpl(
|
||||
}
|
||||
}
|
||||
|
||||
override fun subscribeAll(after: Long): Flow<List<UpdatesWithRelations>> {
|
||||
override fun subscribeAll(after: Long, limit: Long): Flow<List<UpdatesWithRelations>> {
|
||||
return databaseHandler.subscribeToList {
|
||||
updatesViewQueries.updates(after, updateWithRelationMapper)
|
||||
updatesViewQueries.getRecentUpdates(after, limit, updateWithRelationMapper)
|
||||
}.map {
|
||||
databaseHandler.awaitList { (databaseHandler as AndroidDatabaseHandler).getUpdatesQuery(after) }
|
||||
databaseHandler.awaitList { (databaseHandler as AndroidDatabaseHandler).getUpdatesQuery(after, limit) }
|
||||
.map(updatesViewMapper)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user