update spring-boot
* add TEST_A and TEST_B courses for testing during summer break
This commit is contained in:
@ -49,7 +49,7 @@ class APIController {
|
||||
|
||||
companion object {
|
||||
const val apiVersion = "1.2.0"
|
||||
const val softwareVersion = "1.2.5"
|
||||
const val softwareVersion = "1.2.6"
|
||||
val startTime = System.currentTimeMillis() / 1000
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ package org.mosad.thecitadelofricks.controller
|
||||
|
||||
import com.google.gson.Gson
|
||||
import kotlinx.coroutines.*
|
||||
import org.jsoup.Jsoup
|
||||
import org.mosad.thecitadelofricks.*
|
||||
import org.mosad.thecitadelofricks.hsoparser.CourseListParser
|
||||
import org.mosad.thecitadelofricks.hsoparser.MensaParser
|
||||
@ -61,6 +62,20 @@ class CacheController {
|
||||
* @return timetable of the course (Type: [TimetableCourseWeek])
|
||||
*/
|
||||
fun getTimetable(courseName: String, weekIndex: Int): TimetableCourseWeek = runBlocking {
|
||||
|
||||
// TODO just for testing
|
||||
if (courseName == "TEST_A" || courseName == "TEST_B") {
|
||||
val currentTime = System.currentTimeMillis() / 1000
|
||||
val timetableLink = "https://mosad.xyz"
|
||||
val weekNumberYear = 0
|
||||
|
||||
val htmlFile = File(CacheController::class.java.getResource("/html/Timetable_normal-week.html").path)
|
||||
val htmlDoc = Jsoup.parse(htmlFile,"UTF-8", "https://www.hs-offenburg.de/")
|
||||
val timetableTest = TimetableParser().parseTimeTable(htmlDoc)
|
||||
|
||||
return@runBlocking TimetableCourseWeek(TimetableCourseMeta(currentTime, courseName, weekIndex, weekNumberYear, timetableLink), timetableTest)
|
||||
}
|
||||
|
||||
return@runBlocking timetableList.getOrPut("$courseName-$weekIndex") {
|
||||
val timetableLink = courseList.courses[courseName]
|
||||
?.courseLink
|
||||
@ -127,6 +142,10 @@ class CacheController {
|
||||
courseList = CoursesList(CoursesMeta(System.currentTimeMillis() / 1000, it.size), it)
|
||||
}
|
||||
|
||||
// TODO just for testing
|
||||
courseList.courses["TEST_A"] = Course("TEST_A", "https://mosad.xyz")
|
||||
courseList.courses["TEST_B"] = Course("TEST_B", "https://mosad.xyz")
|
||||
|
||||
logger.info("Updated courses successful at ${Date(courseList.meta.updateTime * 1000)}")
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user