allow sorting by total chapters for library view (#811)

* allow sorting by total chapters for library view

* allow sorting by total chapters for library view

* Changed to remove query per manga.
This commit is contained in:
Carlos
2017-05-31 15:50:21 -04:00
committed by inorichi
parent e85841784c
commit 1089c25b8f
6 changed files with 28 additions and 2 deletions

View File

@@ -98,4 +98,7 @@ interface MangaQueries : DbProvider {
.observesTables(MangaTable.TABLE)
.build())
.prepare()
fun getTotalChapterManga() = db.get().listOfObjects(Manga::class.java)
.withQuery(RawQuery.builder().query(getTotalChapterMangaQuery()).observesTables(MangaTable.TABLE).build()).prepare();
}

View File

@@ -93,6 +93,15 @@ fun getLastReadMangaQuery() = """
ORDER BY max DESC
"""
fun getTotalChapterMangaQuery()= """
SELECT ${Manga.TABLE}.*
FROM ${Manga.TABLE}
JOIN ${Chapter.TABLE}
ON ${Manga.TABLE}.${Manga.COL_ID} = ${Chapter.TABLE}.${Chapter.COL_MANGA_ID}
GROUP BY ${Manga.TABLE}.${Manga.COL_ID}
ORDER by COUNT(*)
"""
/**
* Query to get the categories for a manga.
*/