Tidies up the startup code to make it more readable
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
3e2f0ca681
commit
0aaa29b1e2
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user