database changes for mergedsources
This commit is contained in:
parent
aefa7a1a4a
commit
42c7669bca
@ -7,6 +7,8 @@ import eu.kanade.tachiyomi.data.database.tables.ChapterTable
|
|||||||
import eu.kanade.tachiyomi.data.database.tables.HistoryTable
|
import eu.kanade.tachiyomi.data.database.tables.HistoryTable
|
||||||
import eu.kanade.tachiyomi.data.database.tables.MangaCategoryTable
|
import eu.kanade.tachiyomi.data.database.tables.MangaCategoryTable
|
||||||
import eu.kanade.tachiyomi.data.database.tables.MangaTable
|
import eu.kanade.tachiyomi.data.database.tables.MangaTable
|
||||||
|
import eu.kanade.tachiyomi.data.database.tables.MergedTable
|
||||||
|
import eu.kanade.tachiyomi.data.database.tables.SearchMetadataTable
|
||||||
import eu.kanade.tachiyomi.data.database.tables.TrackTable
|
import eu.kanade.tachiyomi.data.database.tables.TrackTable
|
||||||
import exh.metadata.sql.tables.SearchMetadataTable
|
import exh.metadata.sql.tables.SearchMetadataTable
|
||||||
import exh.metadata.sql.tables.SearchTagTable
|
import exh.metadata.sql.tables.SearchTagTable
|
||||||
@ -38,6 +40,9 @@ class DbOpenCallback : SupportSQLiteOpenHelper.Callback(DATABASE_VERSION) {
|
|||||||
execSQL(SearchTagTable.createTableQuery)
|
execSQL(SearchTagTable.createTableQuery)
|
||||||
execSQL(SearchTitleTable.createTableQuery)
|
execSQL(SearchTitleTable.createTableQuery)
|
||||||
// EXH <--
|
// EXH <--
|
||||||
|
// AZ -->
|
||||||
|
execSQL(MergedTable.createTableQuery)
|
||||||
|
// AZ <--
|
||||||
|
|
||||||
// DB indexes
|
// DB indexes
|
||||||
execSQL(MangaTable.createUrlIndexQuery)
|
execSQL(MangaTable.createUrlIndexQuery)
|
||||||
@ -53,6 +58,9 @@ class DbOpenCallback : SupportSQLiteOpenHelper.Callback(DATABASE_VERSION) {
|
|||||||
db.execSQL(SearchTitleTable.createMangaIdIndexQuery)
|
db.execSQL(SearchTitleTable.createMangaIdIndexQuery)
|
||||||
db.execSQL(SearchTitleTable.createTitleIndexQuery)
|
db.execSQL(SearchTitleTable.createTitleIndexQuery)
|
||||||
// EXH <--
|
// EXH <--
|
||||||
|
// AZ -->
|
||||||
|
execSQL(MergedTable.createIndexQuery)
|
||||||
|
// AZ <--
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onUpgrade(db: SupportSQLiteDatabase, oldVersion: Int, newVersion: Int) {
|
override fun onUpgrade(db: SupportSQLiteDatabase, oldVersion: Int, newVersion: Int) {
|
||||||
|
@ -26,6 +26,13 @@ interface ChapterQueries : DbProvider {
|
|||||||
.build())
|
.build())
|
||||||
.prepare()
|
.prepare()
|
||||||
|
|
||||||
|
fun getChaptersByMergedMangaId(mangaId: Long) = db.get()
|
||||||
|
.listOfObjects(Chapter::class.java)
|
||||||
|
.withQuery(RawQuery.builder()
|
||||||
|
.query(getMergedChaptersQuery(mangaId))
|
||||||
|
.build())
|
||||||
|
.prepare()
|
||||||
|
|
||||||
fun getRecentChapters(date: Date) = db.get()
|
fun getRecentChapters(date: Date) = db.get()
|
||||||
.listOfObjects(MangaChapter::class.java)
|
.listOfObjects(MangaChapter::class.java)
|
||||||
.withQuery(
|
.withQuery(
|
||||||
|
@ -74,6 +74,13 @@ interface MangaQueries : DbProvider {
|
|||||||
)
|
)
|
||||||
.prepare()
|
.prepare()
|
||||||
|
|
||||||
|
fun getMergedMangas(id: Long) = db.get()
|
||||||
|
.listOfObjects(Manga::class.java)
|
||||||
|
.withQuery(RawQuery.builder()
|
||||||
|
.query(getMergedMangaQuery(id))
|
||||||
|
.build())
|
||||||
|
.prepare()
|
||||||
|
|
||||||
fun insertManga(manga: Manga) = db.put().`object`(manga).prepare()
|
fun insertManga(manga: Manga) = db.put().`object`(manga).prepare()
|
||||||
|
|
||||||
fun insertMangas(mangas: List<Manga>) = db.put().objects(mangas).prepare()
|
fun insertMangas(mangas: List<Manga>) = db.put().objects(mangas).prepare()
|
||||||
|
@ -5,6 +5,31 @@ import eu.kanade.tachiyomi.data.database.tables.ChapterTable as Chapter
|
|||||||
import eu.kanade.tachiyomi.data.database.tables.HistoryTable as History
|
import eu.kanade.tachiyomi.data.database.tables.HistoryTable as History
|
||||||
import eu.kanade.tachiyomi.data.database.tables.MangaCategoryTable as MangaCategory
|
import eu.kanade.tachiyomi.data.database.tables.MangaCategoryTable as MangaCategory
|
||||||
import eu.kanade.tachiyomi.data.database.tables.MangaTable as Manga
|
import eu.kanade.tachiyomi.data.database.tables.MangaTable as Manga
|
||||||
|
import eu.kanade.tachiyomi.data.database.tables.MergedTable as Merged
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query to get the manga merged into a merged manga
|
||||||
|
*/
|
||||||
|
fun getMergedMangaQuery(id: Long) = """
|
||||||
|
SELECT ${Manga.TABLE}.*
|
||||||
|
FROM (
|
||||||
|
SELECT ${Merged.COL_MANGA_ID} FROM ${Merged.TABLE} WHERE $(Merged.COL_MERGE_ID} = $id
|
||||||
|
) AS M
|
||||||
|
JOIN ${Manga.TABLE}
|
||||||
|
ON ${Manga.TABLE}.${Manga.COL_ID} = M.${Merged.COL_MANGA_ID}
|
||||||
|
"""
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query to get the chapters of all manga in a merged manga
|
||||||
|
*/
|
||||||
|
fun getMergedChaptersQuery(id: Long) = """
|
||||||
|
SELECT ${Chapter.TABLE}.*
|
||||||
|
FROM (
|
||||||
|
SELECT ${Merged.COL_MANGA_ID} FROM ${Merged.TABLE} WHERE $(Merged.COL_MERGE_ID} = $id
|
||||||
|
) AS M
|
||||||
|
JOIN ${Chapter.TABLE}
|
||||||
|
ON ${Chapter.TABLE}.${Chapter.COL_MANGA_ID} = M.${Merged.COL_MANGA_ID}
|
||||||
|
"""
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query to get the manga from the library, with their categories and unread count.
|
* Query to get the manga from the library, with their categories and unread count.
|
||||||
|
19
app/src/main/java/eu/kanade/tachiyomi/data/database/tables/MergedTable.kt
Executable file
19
app/src/main/java/eu/kanade/tachiyomi/data/database/tables/MergedTable.kt
Executable file
@ -0,0 +1,19 @@
|
|||||||
|
package eu.kanade.tachiyomi.data.database.tables
|
||||||
|
|
||||||
|
object MergedTable {
|
||||||
|
|
||||||
|
const val TABLE = "merged"
|
||||||
|
|
||||||
|
const val COL_MERGE_ID = "mergeID"
|
||||||
|
|
||||||
|
const val COL_MANGA_ID = "mangaID"
|
||||||
|
|
||||||
|
val createTableQuery: String
|
||||||
|
get() = """CREATE TABLE $TABLE(
|
||||||
|
$COL_MERGE_ID INTEGER NOT NULL,
|
||||||
|
$COL_MANGA_ID INTEGER NOT NULL
|
||||||
|
)"""
|
||||||
|
|
||||||
|
val createIndexQuery: String
|
||||||
|
get() = "CREATE INDEX ${TABLE}_${COL_MERGE_ID}_index ON $TABLE($COL_MERGE_ID)"
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user