fix(recents): Partially revert SQLDelight migration

getAllRecentsTypes query is too cursed, will need some refactoring
This commit is contained in:
Ahmad Ansori Palembani 2024-08-27 10:01:17 +07:00
parent 6e3eaad481
commit 0d9ffc2206
Signed by: null2264
GPG key ID: BA64F8B60AF3EFB6
3 changed files with 43 additions and 1 deletions

View file

@ -142,4 +142,35 @@ interface HistoryQueries : DbProvider {
.build(),
)
.prepare()
/**
* Returns history of recent manga containing last read chapter in 25s
* @param date recent date range
* @offset offset the db by
*/
fun getAllRecentsTypes(
search: String = "",
includeRead: Boolean,
endless: Boolean,
offset: Int,
isResuming: Boolean,
) = db.get()
.listOfObjects(MangaChapterHistory::class.java)
.withQuery(
RawQuery.builder()
.query(
getAllRecentsType(
search.sqLite,
includeRead,
endless,
offset,
isResuming,
),
)
// .args(date.time, startDate.time)
.observesTables(HistoryTable.TABLE)
.build(),
)
.withGetResolver(MangaChapterHistoryGetResolver.INSTANCE)
.prepare()
}

View file

@ -17,6 +17,7 @@ import eu.kanade.tachiyomi.source.SourceManager
import eu.kanade.tachiyomi.ui.base.presenter.BaseCoroutinePresenter
import eu.kanade.tachiyomi.util.chapter.ChapterFilter
import eu.kanade.tachiyomi.util.chapter.ChapterSort
import eu.kanade.tachiyomi.util.system.executeOnIO
import eu.kanade.tachiyomi.util.system.launchIO
import eu.kanade.tachiyomi.util.system.launchUI
import eu.kanade.tachiyomi.util.system.toast
@ -171,6 +172,8 @@ class RecentsPresenter(
var extraCount = 0
val cReading: List<MangaChapterHistory> = when (viewType) {
RecentsViewType.GroupedAll, RecentsViewType.UngroupedAll -> {
// FIXME
/*
getRecents.awaitAll(
showRead,
true,
@ -179,6 +182,14 @@ class RecentsPresenter(
query,
(if (isCustom) ENDLESS_LIMIT else pageOffset).toLong(),
)
*/
db.getAllRecentsTypes(
query,
showRead,
isEndless,
if (isCustom) ENDLESS_LIMIT else pageOffset,
!updatePageCount && !isOnFirstPage,
).executeOnIO()
}
RecentsViewType.History -> {
val items = if (groupChaptersHistory == GroupType.BySeries) {

View file

@ -62,7 +62,7 @@ AND (
ORDER BY max_last_read.history_last_read DESC
LIMIT :limit OFFSET :offset;
getRecentsAll: -- AKA insanity
getRecentsAll: -- FIXME: This is insanity, require refactoring
SELECT * FROM (
SELECT
mangas.*,