Tidies up the startup code to make it more readable
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
aarbit 2024-07-01 21:23:57 -05:00
parent 3e2f0ca681
commit 0aaa29b1e2

View File

@ -21,19 +21,14 @@ class StartupService(
@Async @Async
@EventListener(ApplicationStartedEvent::class) @EventListener(ApplicationStartedEvent::class)
suspend fun onStartup() { suspend fun onStartup() {
if (withContext(ioDispatcher) { val cacheType = if (withContext(ioDispatcher) { albumRepository.count() } == 0L) {
albumRepository.count() CacheType.ALL}
} == 0L) { else {
coroutineScope { CacheType.NEW
launch { }
albumCacheService.cacheAlbums(CacheType.ALL) coroutineScope {
} launch {
} albumCacheService.cacheAlbums(cacheType)
} else {
coroutineScope {
launch {
albumCacheService.cacheAlbums(CacheType.NEW)
}
} }
} }
} }