Browse Source

added request counter

pull/18/head
Jannik 3 years ago
parent
commit
cef6e84e37
  1. 6
      src/main/kotlin/org/mosad/thecitadelofricks/APIController.kt
  2. 1
      src/main/kotlin/org/mosad/thecitadelofricks/DataTypes.kt

6
src/main/kotlin/org/mosad/thecitadelofricks/APIController.kt

@ -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,

1
src/main/kotlin/org/mosad/thecitadelofricks/DataTypes.kt

@ -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,

Loading…
Cancel
Save

Du besuchst diese Seite mit einem veralteten IPv4-Internetzugang. Möglicherweise treten in Zukunft Probleme mit der Erreichbarkeit und Performance auf. Bitte frage deinen Internetanbieter oder Netzwerkadministrator nach IPv6-Unterstützung.
You are visiting this site with an outdated IPv4 internet access. You may experience problems with accessibility and performance in the future. Please ask your ISP or network administrator for IPv6 support.
Weitere Infos | More Information
Klicke zum schließen | Click to close