Browse Source

added more metrics to the status request

pull/18/head
Jannik 3 years ago
parent
commit
e89201c951
Signed by: Seil0
GPG Key ID: E8459F3723C52C24
  1. 10
      src/main/kotlin/org/mosad/thecitadelofricks/APIController.kt
  2. 2
      src/main/kotlin/org/mosad/thecitadelofricks/CacheController.kt
  3. 2
      src/main/kotlin/org/mosad/thecitadelofricks/DataTypes.kt

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

@ -24,6 +24,7 @@ package org.mosad.thecitadelofricks
import org.mosad.thecitadelofricks.CacheController.Companion.courseList
import org.mosad.thecitadelofricks.CacheController.Companion.mensaMenu
import org.mosad.thecitadelofricks.CacheController.Companion.timetableList
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.web.bind.annotation.RequestMapping
@ -33,6 +34,7 @@ import java.net.HttpURLConnection
import java.net.URL
import java.time.LocalDateTime
import java.util.*
import java.util.stream.Collectors
import kotlin.collections.ArrayList
import kotlin.collections.HashSet
@ -42,8 +44,8 @@ class APIController {
private val logger: Logger = LoggerFactory.getLogger(APIController::class.java)
private val cache = CacheController()
private val softwareVersion = "1.1.3"
private val apiVersion = "1.1.1"
private val softwareVersion = "1.1.3"
private val startTime = System.currentTimeMillis() / 1000
private var requestCount = 0
@ -141,6 +143,10 @@ class APIController {
val minutes = (currentTime - startTime) % 3600 / 60
val hours = (currentTime - startTime) % 86400 / 3600
val days = (currentTime - startTime) / 86400
val timetableListSize = timetableList.size
val timetableListNames = timetableList.stream().map { x -> x.meta.courseName }.collect(Collectors.toList())
var hsoCode = 999
var swfrCode = 999
logger.info("status request at ${LocalDateTime.now()}!")
@ -168,6 +174,8 @@ class APIController {
apiVersion,
softwareVersion,
requestCount,
timetableListSize,
HashSet(timetableListNames).toString(),
Date(courseList.meta.updateTime * 1000),
Date(mensaMenu.meta.updateTime * 1000),
hsoCode,

2
src/main/kotlin/org/mosad/thecitadelofricks/CacheController.kt

@ -165,8 +165,6 @@ class CacheController {
val initDelay3h = (10800000 - ((currentTime + 3600000) % 10800000)) + 60000
val initDelay1h = (3600000 - ((currentTime + 3600000) % 3600000)) + 60000
println(initDelay1h / 1000)
// update courseList every 24 hours (time in ms)
Timer().scheduleAtFixedRate(initDelay24h, 86400000) {
asyncUpdateCourseList()

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

@ -68,6 +68,8 @@ data class Status(
val apiVersion: String,
val softwareVersion: String,
val requestCount: Int,
val timetableListSize: Int,
val timetableListNames: String,
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