Skip to content

Commit 51bfb35

Browse files
committed
perf: send events outside of db transaction
1 parent 3f64435 commit 51bfb35

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

komga/src/main/kotlin/org/gotson/komga/domain/service/ReadListLifecycle.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,13 @@ class ReadListLifecycle(
109109

110110
fun deleteEmptyReadLists() {
111111
logger.info { "Deleting empty read lists" }
112+
val toDelete = readListRepository.findAllEmpty()
112113
transactionTemplate.executeWithoutResult {
113-
val toDelete = readListRepository.findAllEmpty()
114114
thumbnailReadListRepository.deleteByReadListIds(toDelete.map { it.id })
115115
readListRepository.delete(toDelete.map { it.id })
116-
117-
toDelete.forEach { eventPublisher.publishEvent(DomainEvent.ReadListDeleted(it)) }
118116
}
117+
118+
toDelete.forEach { eventPublisher.publishEvent(DomainEvent.ReadListDeleted(it)) }
119119
}
120120

121121
fun addThumbnail(thumbnail: ThumbnailReadList): ThumbnailReadList {

komga/src/main/kotlin/org/gotson/komga/domain/service/SeriesCollectionLifecycle.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,13 @@ class SeriesCollectionLifecycle(
9595

9696
fun deleteEmptyCollections() {
9797
logger.info { "Deleting empty collections" }
98+
val toDelete = collectionRepository.findAllEmpty()
9899
transactionTemplate.executeWithoutResult {
99-
val toDelete = collectionRepository.findAllEmpty()
100100
thumbnailSeriesCollectionRepository.deleteByCollectionIds(toDelete.map { it.id })
101101
collectionRepository.delete(toDelete.map { it.id })
102-
103-
toDelete.forEach { eventPublisher.publishEvent(DomainEvent.CollectionDeleted(it)) }
104102
}
103+
104+
toDelete.forEach { eventPublisher.publishEvent(DomainEvent.CollectionDeleted(it)) }
105105
}
106106

107107
fun addThumbnail(thumbnail: ThumbnailSeriesCollection): ThumbnailSeriesCollection {

0 commit comments

Comments
 (0)