perf: send events outside of db transaction

This commit is contained in:
Gauthier Roebroeck 2025-09-09 10:08:40 +08:00
parent 3f64435afa
commit 51bfb353e7
2 changed files with 6 additions and 6 deletions

View file

@ -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 {

View file

@ -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 {