mirror of
https://github.com/2martens/tsw-timetable.git
synced 2026-10-17 16:06:51 +02:00
Added logging
This commit is contained in:
+11
@@ -2,6 +2,7 @@ package de.twomartens.timetable.bahnApi.tasks
|
||||
|
||||
import de.twomartens.timetable.bahnApi.model.db.ScheduledFetchTask
|
||||
import de.twomartens.timetable.bahnApi.repository.ScheduledFetchTaskRepository
|
||||
import mu.KotlinLogging
|
||||
import org.springframework.scheduling.annotation.Async
|
||||
|
||||
@Async
|
||||
@@ -10,6 +11,16 @@ open class DeleteScheduledTask(
|
||||
private val scheduledFetchTask: ScheduledFetchTask
|
||||
) : Runnable {
|
||||
override fun run() {
|
||||
log.info {
|
||||
"Delete scheduled fetch task after the fetch occurred: " +
|
||||
"[eva: ${scheduledFetchTask.eva}], " +
|
||||
"[date: ${scheduledFetchTask.fetchedDate}], " +
|
||||
"[time: ${scheduledFetchTask.fetchedTime}]"
|
||||
}
|
||||
scheduledFetchTaskRepository.delete(scheduledFetchTask)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val log = KotlinLogging.logger {}
|
||||
}
|
||||
}
|
||||
+14
-5
@@ -1,24 +1,33 @@
|
||||
package de.twomartens.timetable.bahnApi.tasks
|
||||
|
||||
import de.twomartens.timetable.bahnApi.repository.ScheduledFetchTaskRepository
|
||||
import de.twomartens.timetable.bahnApi.service.BahnApiService
|
||||
import de.twomartens.timetable.bahnApi.service.BahnDatabaseService
|
||||
import de.twomartens.timetable.model.Eva
|
||||
import de.twomartens.timetable.model.Hour
|
||||
import mu.KotlinLogging
|
||||
import org.springframework.scheduling.annotation.Async
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
|
||||
import java.time.LocalDate
|
||||
import java.time.LocalTime
|
||||
|
||||
@Async
|
||||
open class FetchTimetableTask(
|
||||
private val eva: Int,
|
||||
private val eva: Eva,
|
||||
private val date: LocalDate,
|
||||
private val hour: LocalTime,
|
||||
private val hour: Hour,
|
||||
private val bahnApiService: BahnApiService,
|
||||
private val bahnDatabaseService: BahnDatabaseService,
|
||||
private val executor: ThreadPoolTaskExecutor) : Runnable {
|
||||
override fun run() {
|
||||
log.info {
|
||||
"Fetch timetable: [eva: $eva], [date: $date], [hour: $hour]"
|
||||
}
|
||||
val timetable = bahnApiService.fetchTimetable(eva, date, hour)
|
||||
val storeTask = StoreTimetableTask(timetable, date.atTime(hour), bahnDatabaseService)
|
||||
val storeTask = StoreTimetableTask(timetable, date.atTime(hour.value, 0),
|
||||
bahnDatabaseService)
|
||||
executor.execute(storeTask)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val log = KotlinLogging.logger {}
|
||||
}
|
||||
}
|
||||
+6
@@ -2,6 +2,7 @@ package de.twomartens.timetable.bahnApi.tasks
|
||||
|
||||
import de.twomartens.timetable.bahnApi.model.dto.BahnTimetable
|
||||
import de.twomartens.timetable.bahnApi.service.BahnDatabaseService
|
||||
import mu.KotlinLogging
|
||||
import org.springframework.scheduling.annotation.Async
|
||||
import java.time.LocalDateTime
|
||||
|
||||
@@ -12,6 +13,11 @@ open class StoreTimetableTask(
|
||||
private val bahnDatabaseService: BahnDatabaseService
|
||||
) : Runnable {
|
||||
override fun run() {
|
||||
log.info { "Store timetable: [eva: ${timetable.eva}], station: ${timetable.station}]" }
|
||||
bahnDatabaseService.storeTimetable(timetable, dateTime)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val log = KotlinLogging.logger {}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user