From 51bfb353e7433dbf4b08dd52c97db820723040c2 Mon Sep 17 00:00:00 2001 From: Gauthier Roebroeck Date: Tue, 9 Sep 2025 10:08:40 +0800 Subject: [PATCH] perf: send events outside of db transaction --- .../org/gotson/komga/domain/service/ReadListLifecycle.kt | 6 +++--- .../komga/domain/service/SeriesCollectionLifecycle.kt | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/komga/src/main/kotlin/org/gotson/komga/domain/service/ReadListLifecycle.kt b/komga/src/main/kotlin/org/gotson/komga/domain/service/ReadListLifecycle.kt index 66cd53d1..9b4d3c69 100644 --- a/komga/src/main/kotlin/org/gotson/komga/domain/service/ReadListLifecycle.kt +++ b/komga/src/main/kotlin/org/gotson/komga/domain/service/ReadListLifecycle.kt @@ -109,13 +109,13 @@ class ReadListLifecycle( fun deleteEmptyReadLists() { logger.info { "Deleting empty read lists" } + val toDelete = readListRepository.findAllEmpty() transactionTemplate.executeWithoutResult { - val toDelete = readListRepository.findAllEmpty() thumbnailReadListRepository.deleteByReadListIds(toDelete.map { it.id }) readListRepository.delete(toDelete.map { it.id }) - - toDelete.forEach { eventPublisher.publishEvent(DomainEvent.ReadListDeleted(it)) } } + + toDelete.forEach { eventPublisher.publishEvent(DomainEvent.ReadListDeleted(it)) } } fun addThumbnail(thumbnail: ThumbnailReadList): ThumbnailReadList { diff --git a/komga/src/main/kotlin/org/gotson/komga/domain/service/SeriesCollectionLifecycle.kt b/komga/src/main/kotlin/org/gotson/komga/domain/service/SeriesCollectionLifecycle.kt index 8d149b47..2de67f55 100644 --- a/komga/src/main/kotlin/org/gotson/komga/domain/service/SeriesCollectionLifecycle.kt +++ b/komga/src/main/kotlin/org/gotson/komga/domain/service/SeriesCollectionLifecycle.kt @@ -95,13 +95,13 @@ class SeriesCollectionLifecycle( fun deleteEmptyCollections() { logger.info { "Deleting empty collections" } + val toDelete = collectionRepository.findAllEmpty() transactionTemplate.executeWithoutResult { - val toDelete = collectionRepository.findAllEmpty() thumbnailSeriesCollectionRepository.deleteByCollectionIds(toDelete.map { it.id }) collectionRepository.delete(toDelete.map { it.id }) - - toDelete.forEach { eventPublisher.publishEvent(DomainEvent.CollectionDeleted(it)) } } + + toDelete.forEach { eventPublisher.publishEvent(DomainEvent.CollectionDeleted(it)) } } fun addThumbnail(thumbnail: ThumbnailSeriesCollection): ThumbnailSeriesCollection {