mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender.git
synced 2025-08-03 10:19:14 +02:00
update:#82 added schedule for sport update
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
"htwkalender/model"
|
||||
"htwkalender/service/db"
|
||||
"htwkalender/service/functions"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strconv"
|
||||
@@ -19,7 +20,7 @@ import (
|
||||
|
||||
// @TODO: add tests
|
||||
// @TODO: make it like a cron job to fetch the sport courses once a week
|
||||
func RetrieveAndFetchAllSportCourses(app *pocketbase.PocketBase) []model.Event {
|
||||
func FetchAndUpdateSportEvents(app *pocketbase.PocketBase) []model.Event {
|
||||
|
||||
var sportCourseLinks = fetchAllAvailableSportCourses()
|
||||
sportEntries := fetchHTWKSportCourses(sportCourseLinks)
|
||||
@@ -55,6 +56,11 @@ func RetrieveAndFetchAllSportCourses(app *pocketbase.PocketBase) []model.Event {
|
||||
}
|
||||
}
|
||||
|
||||
err = db.DeleteAllEventsForCourse(app, "Sport", functions.GetCurrentSemesterString())
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// save events to database
|
||||
savedEvents, err := db.SaveEvents(events, app)
|
||||
|
||||
|
Reference in New Issue
Block a user