mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender.git
synced 2025-08-04 02:39:14 +02:00
fix:#46 updated fetcher and empty course issue
This commit is contained in:
@@ -120,14 +120,12 @@ func DeleteAllEvents(app *pocketbase.PocketBase) error {
|
||||
// 3. Save all events for the course and the semester
|
||||
// If the update was successful, nil is returned
|
||||
// If the update was not successful, an error is returned
|
||||
func UpdateModulesForCourse(app *pocketbase.PocketBase, course string) (model.Events, error) {
|
||||
func UpdateModulesForCourse(app *pocketbase.PocketBase, seminarGroup model.SeminarGroup) (model.Events, error) {
|
||||
|
||||
seminarGroup, err := v1.GetSeminarGroupEventsFromHTML(course)
|
||||
seminarGroup, err := v1.FetchAndParse(seminarGroup.Semester, seminarGroup.Course)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
seminarGroup = v1.ClearEmptySeminarGroups(seminarGroup)
|
||||
seminarGroup = v1.ReplaceEmptyEventNames(seminarGroup)
|
||||
|
||||
//check if events in the seminarGroups Events are already in the database
|
||||
@@ -136,7 +134,7 @@ func UpdateModulesForCourse(app *pocketbase.PocketBase, course string) (model.Ev
|
||||
//if there are no events in the database, save the new events
|
||||
|
||||
//get all events for the course and the semester
|
||||
dbEvents, err := db.GetAllEventsForCourse(app, course)
|
||||
dbEvents, err := db.GetAllEventsForCourse(app, seminarGroup.Course)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -182,7 +180,7 @@ func UpdateModulesForCourse(app *pocketbase.PocketBase, course string) (model.Ev
|
||||
return nil, err
|
||||
}
|
||||
|
||||
slog.Info("Course: " + course + " - Event changes: " + strconv.FormatInt(int64(len(insertList)), 10) + " new events, " + strconv.FormatInt(int64(len(deleteList)), 10) + " deleted events")
|
||||
slog.Info("Course: " + seminarGroup.Course + " - Event changes: " + strconv.FormatInt(int64(len(insertList)), 10) + " new events, " + strconv.FormatInt(int64(len(deleteList)), 10) + " deleted events")
|
||||
return savedEvents, nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user