fix sorting

This commit is contained in:
Aria Moradi
2021-09-27 20:27:40 +03:30
parent d4d6d7e12f
commit 15ec20c65d

View File

@@ -11,7 +11,7 @@ import eu.kanade.tachiyomi.source.model.SChapter
import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.util.chapter.ChapterRecognition import eu.kanade.tachiyomi.util.chapter.ChapterRecognition
import org.jetbrains.exposed.dao.id.EntityID import org.jetbrains.exposed.dao.id.EntityID
import org.jetbrains.exposed.sql.SortOrder.DESC import org.jetbrains.exposed.sql.SortOrder
import org.jetbrains.exposed.sql.and import org.jetbrains.exposed.sql.and
import org.jetbrains.exposed.sql.deleteWhere import org.jetbrains.exposed.sql.deleteWhere
import org.jetbrains.exposed.sql.insert import org.jetbrains.exposed.sql.insert
@@ -41,7 +41,7 @@ object Chapter {
getSourceChapters(mangaId) getSourceChapters(mangaId)
} else { } else {
transaction { transaction {
ChapterTable.select { ChapterTable.manga eq mangaId }.orderBy(ChapterTable.sourceOrder to DESC) ChapterTable.select { ChapterTable.manga eq mangaId }.orderBy(ChapterTable.sourceOrder to SortOrder.DESC)
.map { .map {
ChapterTable.toDataClass(it) ChapterTable.toDataClass(it)
} }
@@ -322,18 +322,15 @@ object Chapter {
fun getRecentChapters(): List<MangaChapterDataClass> { fun getRecentChapters(): List<MangaChapterDataClass> {
return transaction { return transaction {
val x = (ChapterTable innerJoin MangaTable) (ChapterTable innerJoin MangaTable)
// .selectAll()
.select { (MangaTable.inLibrary eq true) and (ChapterTable.fetchedAt greater MangaTable.inLibraryAt) } .select { (MangaTable.inLibrary eq true) and (ChapterTable.fetchedAt greater MangaTable.inLibraryAt) }
.orderBy(ChapterTable.fetchedAt to SortOrder.DESC)
println(x.count()) .map {
MangaChapterDataClass(
x.map { MangaTable.toDataClass(it),
MangaChapterDataClass( ChapterTable.toDataClass(it)
MangaTable.toDataClass(it), )
ChapterTable.toDataClass(it) }
)
}
} }
} }
} }