added request counter

This commit is contained in:
Jannik 2019-03-18 19:11:20 +01:00
parent cf0327bc88
commit cef6e84e37
2 changed files with 7 additions and 0 deletions

View File

@ -46,6 +46,7 @@ class APIController {
// Controller stuff
var logger: Logger = LoggerFactory.getLogger(APIController::class.java)
private var requestCount = 0
private val startTime = System.currentTimeMillis() / 1000
private val softwareVersion = "1.0.2"
private val apiVersion = "1.0.1"
@ -90,12 +91,14 @@ class APIController {
@RequestMapping("/courses")
fun courses(): CoursesList {
logger.info("courses request at ${LocalDateTime.now()}!")
requestCount++
return CoursesList(CoursesMeta(coursesLastUpdate, coursesLinkList.size), coursesLinkList)
}
@RequestMapping("/mensamenu")
fun mensamenu(): Mensa {
logger.info("mensamenu request at ${LocalDateTime.now()}!")
requestCount++
return Mensa(MensaMeta(mensaLastUpdate, mensaName), mensaCurrentWeek, mensaNextWeek)
}
@ -105,6 +108,7 @@ class APIController {
@RequestParam(value = "week", defaultValue = "0") week: Int
): TimetableCourseWeek {
logger.info("timetable request at ${LocalDateTime.now()}!")
requestCount++
checkTimetableCourse(courseName, week) // check if we need to update and perform the update if so
return timetableList.stream().filter { x -> x.meta.courseName == courseName && x.meta.week == week }.findAny().orElse(null)
}
@ -118,6 +122,7 @@ class APIController {
var hsoCode = 999
var swfrCode = 999
logger.info("status request at ${LocalDateTime.now()}!")
requestCount++
try {
val hsoURL = URL("https://www.hs-offenburg.de/")
@ -136,6 +141,7 @@ class APIController {
"$days days, $hours:$minutes",
apiVersion,
softwareVersion,
requestCount,
Date(coursesLastUpdate * 1000),
Date(mensaLastUpdate * 1000),
hsoCode,

View File

@ -67,6 +67,7 @@ data class Status(
val uptime: String,
val apiVersion: String,
val softwareVersion: String,
val requestCount: Int,
val coursesLastUpdate: Date,
val mensaLastUpdate: Date,
val hsoResponseCode: Int,