Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
1d614a06c4
|
|||
3f10c8afaa
|
|||
9de1e295dd
|
|||
6287d4582d
|
@ -1,12 +1,12 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'org.jetbrains.kotlin.jvm' version '1.3.72'
|
id 'org.jetbrains.kotlin.jvm' version '1.3.72'
|
||||||
id 'org.jetbrains.kotlin.plugin.spring' version '1.3.72'
|
id 'org.jetbrains.kotlin.plugin.spring' version '1.3.72'
|
||||||
id 'org.springframework.boot' version '2.3.0.RELEASE'
|
id 'org.springframework.boot' version '2.3.2.RELEASE'
|
||||||
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
|
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
|
||||||
}
|
}
|
||||||
|
|
||||||
group 'org.mosad'
|
group 'org.mosad'
|
||||||
version '1.2.5'
|
version '1.2.7'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
jcenter()
|
||||||
@ -15,7 +15,7 @@ repositories {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||||
implementation 'org.jetbrains.kotlin:kotlin-stdlib'
|
implementation 'org.jetbrains.kotlin:kotlin-stdlib'
|
||||||
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.7'
|
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.8'
|
||||||
implementation 'org.jsoup:jsoup:1.13.1'
|
implementation 'org.jsoup:jsoup:1.13.1'
|
||||||
implementation 'com.google.code.gson:gson:2.8.6'
|
implementation 'com.google.code.gson:gson:2.8.6'
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ class APIController {
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val apiVersion = "1.2.0"
|
const val apiVersion = "1.2.0"
|
||||||
const val softwareVersion = "1.2.5"
|
const val softwareVersion = "1.2.7"
|
||||||
val startTime = System.currentTimeMillis() / 1000
|
val startTime = System.currentTimeMillis() / 1000
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ data class Course(val courseName: String, val courseLink: String)
|
|||||||
|
|
||||||
data class CoursesMeta(val updateTime: Long = 0, val totalCourses: Int = 0)
|
data class CoursesMeta(val updateTime: Long = 0, val totalCourses: Int = 0)
|
||||||
|
|
||||||
data class CoursesList(val meta: CoursesMeta = CoursesMeta(), val courses: HashMap<String, Course> = HashMap())
|
data class CoursesList(val meta: CoursesMeta = CoursesMeta(), val courses: SortedMap<String, Course>)
|
||||||
data class CoursesListRet(val meta: CoursesMeta = CoursesMeta(), val courses: ArrayList<Course> = ArrayList())
|
data class CoursesListRet(val meta: CoursesMeta = CoursesMeta(), val courses: ArrayList<Course> = ArrayList())
|
||||||
|
|
||||||
// data classes for the Mensa part
|
// data classes for the Mensa part
|
||||||
|
@ -24,15 +24,14 @@ package org.mosad.thecitadelofricks.controller
|
|||||||
|
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
|
import org.jsoup.Jsoup
|
||||||
import org.mosad.thecitadelofricks.*
|
import org.mosad.thecitadelofricks.*
|
||||||
import org.mosad.thecitadelofricks.hsoparser.CourseListParser
|
import org.mosad.thecitadelofricks.hsoparser.CourseListParser
|
||||||
import org.mosad.thecitadelofricks.hsoparser.MensaParser
|
import org.mosad.thecitadelofricks.hsoparser.MensaParser
|
||||||
import org.mosad.thecitadelofricks.hsoparser.TimetableParser
|
import org.mosad.thecitadelofricks.hsoparser.TimetableParser
|
||||||
import org.slf4j.Logger
|
import org.slf4j.Logger
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import java.io.BufferedWriter
|
import java.io.*
|
||||||
import java.io.File
|
|
||||||
import java.io.FileWriter
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.concurrent.Executors
|
import java.util.concurrent.Executors
|
||||||
import kotlin.collections.ArrayList
|
import kotlin.collections.ArrayList
|
||||||
@ -50,7 +49,7 @@ class CacheController {
|
|||||||
companion object{
|
companion object{
|
||||||
private val logger: Logger = LoggerFactory.getLogger(CacheController::class.java)
|
private val logger: Logger = LoggerFactory.getLogger(CacheController::class.java)
|
||||||
|
|
||||||
var courseList = CoursesList()
|
var courseList = CoursesList(CoursesMeta(), sortedMapOf())
|
||||||
var mensaMenu = MensaMenu(MensaMeta(0,""), MensaWeek(), MensaWeek())
|
var mensaMenu = MensaMenu(MensaMeta(0,""), MensaWeek(), MensaWeek())
|
||||||
var timetableList = HashMap<String, TimetableCourseWeek>() // this list contains all timetables
|
var timetableList = HashMap<String, TimetableCourseWeek>() // this list contains all timetables
|
||||||
|
|
||||||
@ -61,6 +60,20 @@ class CacheController {
|
|||||||
* @return timetable of the course (Type: [TimetableCourseWeek])
|
* @return timetable of the course (Type: [TimetableCourseWeek])
|
||||||
*/
|
*/
|
||||||
fun getTimetable(courseName: String, weekIndex: Int): TimetableCourseWeek = runBlocking {
|
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 instr = javaClass.getResourceAsStream("/html/Timetable_normal-week.html")
|
||||||
|
|
||||||
|
val htmlDoc = Jsoup.parse(instr,"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") {
|
return@runBlocking timetableList.getOrPut("$courseName-$weekIndex") {
|
||||||
val timetableLink = courseList.courses[courseName]
|
val timetableLink = courseList.courses[courseName]
|
||||||
?.courseLink
|
?.courseLink
|
||||||
@ -124,9 +137,13 @@ class CacheController {
|
|||||||
*/
|
*/
|
||||||
private fun asyncUpdateCourseList() = GlobalScope.launch {
|
private fun asyncUpdateCourseList() = GlobalScope.launch {
|
||||||
CourseListParser().getCourseLinks(StartupController.courseListURL)?.let {
|
CourseListParser().getCourseLinks(StartupController.courseListURL)?.let {
|
||||||
courseList = CoursesList(CoursesMeta(System.currentTimeMillis() / 1000, it.size), it)
|
courseList = CoursesList(CoursesMeta(System.currentTimeMillis() / 1000, it.size), it.toSortedMap())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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)}")
|
logger.info("Updated courses successful at ${Date(courseList.meta.updateTime * 1000)}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
1726
src/main/resources/html/Timetable_normal-week.html
Normal file
1726
src/main/resources/html/Timetable_normal-week.html
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user