mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 15:41:52 +01:00
Replace history query with actual upsert
This commit is contained in:
parent
0dbe82c781
commit
cd0294b1b6
@ -136,6 +136,13 @@ android {
|
|||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
jvmTarget = JavaVersion.VERSION_1_8.toString()
|
jvmTarget = JavaVersion.VERSION_1_8.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sqldelight {
|
||||||
|
database("Database") {
|
||||||
|
packageName = "eu.kanade.tachiyomi"
|
||||||
|
dialect = "sqlite:3.24"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
@ -92,24 +92,14 @@ class HistoryRepositoryImpl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun upsertHistory(historyUpdate: HistoryUpdate) {
|
override suspend fun upsertHistory(historyUpdate: HistoryUpdate) {
|
||||||
try {
|
|
||||||
try {
|
try {
|
||||||
handler.await {
|
handler.await {
|
||||||
historyQueries.insert(
|
historyQueries.upsert(
|
||||||
historyUpdate.chapterId,
|
historyUpdate.chapterId,
|
||||||
historyUpdate.readAt,
|
historyUpdate.readAt,
|
||||||
historyUpdate.sessionReadDuration,
|
historyUpdate.sessionReadDuration,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
|
||||||
handler.await {
|
|
||||||
historyQueries.update(
|
|
||||||
historyUpdate.readAt,
|
|
||||||
historyUpdate.sessionReadDuration,
|
|
||||||
historyUpdate.chapterId,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
logcat(LogPriority.ERROR, throwable = e)
|
logcat(LogPriority.ERROR, throwable = e)
|
||||||
}
|
}
|
||||||
|
@ -30,16 +30,6 @@ interface HistoryQueries : DbProvider {
|
|||||||
)
|
)
|
||||||
.prepare()
|
.prepare()
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the history last read.
|
|
||||||
* Inserts history object if not yet in database
|
|
||||||
* @param history history object
|
|
||||||
*/
|
|
||||||
fun upsertHistoryLastRead(history: History) = db.put()
|
|
||||||
.`object`(history)
|
|
||||||
.withPutResolver(HistoryUpsertResolver())
|
|
||||||
.prepare()
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the history last read.
|
* Updates the history last read.
|
||||||
* Inserts history object if not yet in database
|
* Inserts history object if not yet in database
|
||||||
|
@ -36,12 +36,12 @@ removeResettedHistory:
|
|||||||
DELETE FROM history
|
DELETE FROM history
|
||||||
WHERE last_read = 0;
|
WHERE last_read = 0;
|
||||||
|
|
||||||
insert:
|
upsert:
|
||||||
INSERT INTO history(chapter_id, last_read, time_read)
|
INSERT INTO history(chapter_id, last_read, time_read)
|
||||||
VALUES (:chapterId, :readAt, :readDuration);
|
VALUES (:chapterId, :readAt, :time_read)
|
||||||
|
ON CONFLICT(chapter_id)
|
||||||
update:
|
DO UPDATE
|
||||||
UPDATE history
|
SET
|
||||||
SET last_read = :readAt,
|
last_read = :readAt,
|
||||||
time_read = time_read + :sessionReadDuration
|
time_read = time_read + :time_read
|
||||||
WHERE chapter_id = :chapterId;
|
WHERE chapter_id = :chapterId;
|
Loading…
Reference in New Issue
Block a user