Small improvements
- Improve formatting - Fix some typos - Mini code improvements
This commit is contained in:
parent
f9cc9b5e14
commit
993b8f6a71
|
@ -68,7 +68,7 @@ class CacheController {
|
||||||
val currentTime = System.currentTimeMillis() / 1000
|
val currentTime = System.currentTimeMillis() / 1000
|
||||||
val timetableLink = "https://mosad.xyz"
|
val timetableLink = "https://mosad.xyz"
|
||||||
val weekNumberYear = 0
|
val weekNumberYear = 0
|
||||||
val instr = javaClass.getResourceAsStream("/html/Timetable_normal-week.html")
|
val instr = CacheController::class.java.getResourceAsStream("/html/Timetable_normal-week.html")
|
||||||
|
|
||||||
val timetableParser =
|
val timetableParser =
|
||||||
TimetableParser(htmlDoc = Jsoup.parse(instr, "UTF-8", "https://www.hs-offenburg.de/"))
|
TimetableParser(htmlDoc = Jsoup.parse(instr, "UTF-8", "https://www.hs-offenburg.de/"))
|
||||||
|
@ -151,7 +151,7 @@ class CacheController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this function updates the courseList
|
* this function updates the courseList
|
||||||
* during the update process the old data will be returned for a API request
|
* during the update process the old data will be returned for an API request
|
||||||
*/
|
*/
|
||||||
private fun asyncUpdateCourseList() = GlobalScope.launch {
|
private fun asyncUpdateCourseList() = GlobalScope.launch {
|
||||||
CourseListParser().getCourseLinks(StartupController.courseListURL)?.let {
|
CourseListParser().getCourseLinks(StartupController.courseListURL)?.let {
|
||||||
|
@ -167,7 +167,7 @@ class CacheController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this function updates the mensa menu list
|
* this function updates the mensa menu list
|
||||||
* during the update process the old data will be returned for a API request
|
* during the update process the old data will be returned for an API request
|
||||||
*/
|
*/
|
||||||
private fun asyncUpdateMensa() = GlobalScope.launch {
|
private fun asyncUpdateMensa() = GlobalScope.launch {
|
||||||
val mensaCurrentWeek = MensaParser().getMensaMenu(StartupController.mensaMenuURL)
|
val mensaCurrentWeek = MensaParser().getMensaMenu(StartupController.mensaMenuURL)
|
||||||
|
@ -183,7 +183,7 @@ class CacheController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this function updates all existing timetables
|
* this function updates all existing timetables
|
||||||
* during the update process the old data will be returned for a API request
|
* during the update process the old data will be returned for an API request
|
||||||
* a FixedThreadPool is used to make parallel requests for faster updates
|
* a FixedThreadPool is used to make parallel requests for faster updates
|
||||||
*/
|
*/
|
||||||
private fun asyncUpdateTimetables() = GlobalScope.launch {
|
private fun asyncUpdateTimetables() = GlobalScope.launch {
|
||||||
|
|
|
@ -135,7 +135,8 @@ class StartupController {
|
||||||
try {
|
try {
|
||||||
val timetableObject = JsonParser.parseString(bufferedReader.readLine()).asJsonObject
|
val timetableObject = JsonParser.parseString(bufferedReader.readLine()).asJsonObject
|
||||||
val timetable = Gson().fromJson(timetableObject, TimetableCourseWeek().javaClass)
|
val timetable = Gson().fromJson(timetableObject, TimetableCourseWeek().javaClass)
|
||||||
CacheController.timetableList.put("${timetable.meta.courseName}-${timetable.meta.weekIndex}", timetable)
|
CacheController.timetableList["${timetable.meta.courseName}-${timetable.meta.weekIndex}"] =
|
||||||
|
timetable
|
||||||
} catch (ex: Exception) {
|
} catch (ex: Exception) {
|
||||||
logger.error("error while reading cache", ex)
|
logger.error("error while reading cache", ex)
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -62,7 +62,7 @@ class StatusController {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateTimetableRequests(courseName: String) {
|
fun updateTimetableRequests(courseName: String) {
|
||||||
timetableRequests[courseName] = timetableRequests.getOrPut(courseName) {0} + 1
|
timetableRequests[courseName] = (timetableRequests[courseName] ?: 0) + 1
|
||||||
totalRequests++
|
totalRequests++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -115,8 +115,7 @@ class TimetableParser(timetableURL: String? = null, htmlDoc: Document? = null) {
|
||||||
|
|
||||||
lessonIndexDay++
|
lessonIndexDay++
|
||||||
|
|
||||||
if (element.hasClass("lastcol"))
|
if (element.hasClass("lastcol")) {
|
||||||
{
|
|
||||||
day++
|
day++
|
||||||
lessonIndexDay = 0
|
lessonIndexDay = 0
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue