mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender.git
synced 2025-08-03 02:09:15 +02:00
feat:#104 reordered schedule
This commit is contained in:
@@ -26,20 +26,19 @@ func AddSchedules(app *pocketbase.PocketBase) {
|
|||||||
course.UpdateCourse(app)
|
course.UpdateCourse(app)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Every sunday at 3am clean all courses (5 segments - minute, hour, day, month, weekday) "0 3 * * 0"
|
// Every sunday at 1am clean all courses (5 segments - minute, hour, day, month, weekday) "0 3 * * 0"
|
||||||
scheduler.MustAdd("cleanFeeds", "0 3 * * 0", func() {
|
scheduler.MustAdd("cleanFeeds", "0 1 * * 0", func() {
|
||||||
// clean feeds older than 6 months
|
// clean feeds older than 6 months
|
||||||
feed.ClearFeeds(app.Dao(), 6, time.RealClock{})
|
feed.ClearFeeds(app.Dao(), 6, time.RealClock{})
|
||||||
})
|
})
|
||||||
|
|
||||||
// Every sunday at 2am fetch all sport events (5 segments - minute, hour, day, month, weekday) "0 2 * * 0"
|
// Every sunday at 3am fetch all sport events (5 segments - minute, hour, day, month, weekday) "0 2 * * 0"
|
||||||
scheduler.MustAdd("fetchEvents", "0 2 * * 0", func() {
|
scheduler.MustAdd("fetchSportEvents", "0 3 * * 0", func() {
|
||||||
sport.FetchAndUpdateSportEvents(app)
|
sport.FetchAndUpdateSportEvents(app)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
//delete all events and then fetch all events from remote this should be done every sunday at 2am
|
||||||
//delete all events and then fetch all events from remote this should be done every day at 4am
|
scheduler.MustAdd("fetchEvents", "0 2 * * 0", func() {
|
||||||
scheduler.MustAdd("fetchEvents", "0 4 * * *", func() {
|
|
||||||
err := events.DeleteAllEvents(app)
|
err := events.DeleteAllEvents(app)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
|
@@ -18,8 +18,9 @@ import (
|
|||||||
"github.com/PuerkitoBio/goquery"
|
"github.com/PuerkitoBio/goquery"
|
||||||
)
|
)
|
||||||
|
|
||||||
// @TODO: add tests
|
// FetchAndUpdateSportEvents fetches all sport events from the HTWK sport website
|
||||||
// @TODO: make it like a cron job to fetch the sport courses once a week
|
// it deletes them first and then saves them to the database
|
||||||
|
// It returns all saved events
|
||||||
func FetchAndUpdateSportEvents(app *pocketbase.PocketBase) []model.Event {
|
func FetchAndUpdateSportEvents(app *pocketbase.PocketBase) []model.Event {
|
||||||
|
|
||||||
var sportCourseLinks = fetchAllAvailableSportCourses()
|
var sportCourseLinks = fetchAllAvailableSportCourses()
|
||||||
@@ -56,6 +57,7 @@ func FetchAndUpdateSportEvents(app *pocketbase.PocketBase) []model.Event {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @TODO: delete and save events in one transaction and it only should delete events that are not in the new events list and save events that are not in the database
|
||||||
err = db.DeleteAllEventsForCourse(app, "Sport", functions.GetCurrentSemesterString())
|
err = db.DeleteAllEventsForCourse(app, "Sport", functions.GetCurrentSemesterString())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
|
Reference in New Issue
Block a user