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
@EventListener(ApplicationStartedEvent::class)
suspend fun onStartup() {
if (withContext(ioDispatcher) {
albumRepository.count()
} == 0L) {
coroutineScope {
launch {
albumCacheService.cacheAlbums(CacheType.ALL)
}
}
} else {
coroutineScope {
launch {
albumCacheService.cacheAlbums(CacheType.NEW)
}
val cacheType = if (withContext(ioDispatcher) { albumRepository.count() } == 0L) {
CacheType.ALL}
else {
CacheType.NEW
}
coroutineScope {
launch {
albumCacheService.cacheAlbums(cacheType)
}
}
}