Skip to content

Commit

Permalink
Backup read manga that are not in library
Browse files Browse the repository at this point in the history
  • Loading branch information
jobobby04 committed Feb 6, 2021
1 parent e26ab22 commit e633da5
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ abstract class AbstractBackupManager(protected val context: Context) {
databaseHelper.getFavoriteMangas().executeAsBlocking()

// SY -->
protected fun getReadManga(): List<Manga> =
databaseHelper.getReadNotInLibraryMangas().executeAsBlocking()

/**
* Returns list containing merged manga that are possibly not in the library
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class FullBackupManager(context: Context) : AbstractBackupManager(context) {
var backup: Backup? = null

databaseHelper.inTransaction {
val databaseManga = getFavoriteManga() /* SY --> */ + getMergedManga().filterNot { it.source == MERGED_SOURCE_ID } /* SY <-- */
val databaseManga = getFavoriteManga() /* SY --> */ + getReadManga() + getMergedManga().filterNot { it.source == MERGED_SOURCE_ID } /* SY <-- */

backup = Backup(
backupManga(databaseManga, flags),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ interface MangaQueries : DbProvider {
.prepare()

// SY -->
fun getReadNotInLibraryMangas() = db.get()
.listOfObjects(Manga::class.java)
.withQuery(
RawQuery.builder()
.query(getReadMangaNotInLibraryQuery())
.build()
)
.prepare()

fun updateMangaInfo(manga: Manga) = db.put()
.`object`(manga)
.withPutResolver(MangaInfoPutResolver())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ fun getMergedChaptersQuery() =
ON ${Chapter.TABLE}.${Chapter.COL_MANGA_ID} = M.${Merged.COL_MANGA_ID}
"""

/**
* Query to get manga that are not in library, but have read chapters
*/
fun getReadMangaNotInLibraryQuery() =
"""
SELECT ${Manga.TABLE}.*
FROM ${Manga.TABLE}
WHERE ${Manga.COL_FAVORITE} = 0 AND ${Manga.COL_ID} IN(
SELECT ${Chapter.TABLE}.${Chapter.COL_MANGA_ID} FROM ${Chapter.TABLE} WHERE ${Chapter.COL_READ} = 1
)
"""

/**
* Query to get the manga from the library, with their categories and unread count.
*/
Expand Down

0 comments on commit e633da5

Please sign in to comment.