Skip to content

Commit

Permalink
Use TransactionRunner for running DB queries in a transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
msasikanth committed Jul 30, 2024
1 parent 51ddd79 commit 42a3b45
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class RssRepository(
id = feedId
)

postQueries.transaction {
transactionRunner.invoke {
val feedLastCleanUpAtEpochMilli =
feedLastCleanUpAt?.toEpochMilliseconds()
?: Instant.DISTANT_PAST.toEpochMilliseconds()
Expand Down Expand Up @@ -486,7 +486,7 @@ class RssRepository(

suspend fun updateFeedsLastCleanUpAt(feedIds: List<String>) {
withContext(ioDispatcher) {
feedQueries.transaction {
transactionRunner.invoke {
feedIds.forEach { feedId ->
feedQueries.updateLastCleanUpAt(lastCleanUpAt = Clock.System.now(), id = feedId)
}
Expand All @@ -503,7 +503,7 @@ class RssRepository(
postsAfter: Instant = Instant.DISTANT_PAST
) {
withContext(ioDispatcher) {
postQueries.transaction {
transactionRunner.invoke {
feedIds.forEach { feedId ->
postQueries.markPostsAsRead(sourceId = feedId, after = postsAfter)
}
Expand Down Expand Up @@ -868,7 +868,7 @@ class RssRepository(

suspend fun updatedSourcePinnedPosition(sources: List<Source>) {
withContext(ioDispatcher) {
feedQueries.transaction {
transactionRunner.invoke {
sources.forEachIndexed { index, source ->
feedQueries.updatedPinnedPosition(index.toDouble(), source.id)
feedGroupQueries.updatedPinnedPosition(index.toDouble(), source.id)
Expand Down

0 comments on commit 42a3b45

Please sign in to comment.