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.model.db.ScheduledFetchTask
|
||||||
import de.twomartens.timetable.bahnApi.repository.ScheduledFetchTaskRepository
|
import de.twomartens.timetable.bahnApi.repository.ScheduledFetchTaskRepository
|
||||||
|
import mu.KotlinLogging
|
||||||
import org.springframework.scheduling.annotation.Async
|
import org.springframework.scheduling.annotation.Async
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
@@ -10,6 +11,16 @@ open class DeleteScheduledTask(
|
|||||||
private val scheduledFetchTask: ScheduledFetchTask
|
private val scheduledFetchTask: ScheduledFetchTask
|
||||||
) : Runnable {
|
) : Runnable {
|
||||||
override fun run() {
|
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)
|
scheduledFetchTaskRepository.delete(scheduledFetchTask)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val log = KotlinLogging.logger {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+14
-5
@@ -1,24 +1,33 @@
|
|||||||
package de.twomartens.timetable.bahnApi.tasks
|
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.BahnApiService
|
||||||
import de.twomartens.timetable.bahnApi.service.BahnDatabaseService
|
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.annotation.Async
|
||||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
|
||||||
import java.time.LocalDate
|
import java.time.LocalDate
|
||||||
import java.time.LocalTime
|
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
open class FetchTimetableTask(
|
open class FetchTimetableTask(
|
||||||
private val eva: Int,
|
private val eva: Eva,
|
||||||
private val date: LocalDate,
|
private val date: LocalDate,
|
||||||
private val hour: LocalTime,
|
private val hour: Hour,
|
||||||
private val bahnApiService: BahnApiService,
|
private val bahnApiService: BahnApiService,
|
||||||
private val bahnDatabaseService: BahnDatabaseService,
|
private val bahnDatabaseService: BahnDatabaseService,
|
||||||
private val executor: ThreadPoolTaskExecutor) : Runnable {
|
private val executor: ThreadPoolTaskExecutor) : Runnable {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
|
log.info {
|
||||||
|
"Fetch timetable: [eva: $eva], [date: $date], [hour: $hour]"
|
||||||
|
}
|
||||||
val timetable = bahnApiService.fetchTimetable(eva, date, 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)
|
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.model.dto.BahnTimetable
|
||||||
import de.twomartens.timetable.bahnApi.service.BahnDatabaseService
|
import de.twomartens.timetable.bahnApi.service.BahnDatabaseService
|
||||||
|
import mu.KotlinLogging
|
||||||
import org.springframework.scheduling.annotation.Async
|
import org.springframework.scheduling.annotation.Async
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
|
|
||||||
@@ -12,6 +13,11 @@ open class StoreTimetableTask(
|
|||||||
private val bahnDatabaseService: BahnDatabaseService
|
private val bahnDatabaseService: BahnDatabaseService
|
||||||
) : Runnable {
|
) : Runnable {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
|
log.info { "Store timetable: [eva: ${timetable.eva}], station: ${timetable.station}]" }
|
||||||
bahnDatabaseService.storeTimetable(timetable, dateTime)
|
bahnDatabaseService.storeTimetable(timetable, dateTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val log = KotlinLogging.logger {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user