refactor:#16 event saving shortened

This commit is contained in:
Elmar Kresse
2023-10-23 00:55:11 +02:00
parent 1a12107fb6
commit f8a24aca1b
4 changed files with 19 additions and 44 deletions

View File

@@ -90,11 +90,6 @@ func UpdateModulesForCourse(app *pocketbase.PocketBase, course string) error {
seminarGroups := fetch.GetSeminarGroupsEventsFromHTML(courses)
collection, dbError := db.FindCollection(app, "events")
if dbError != nil {
return apis.NewNotFoundError("Collection not found", dbError)
}
seminarGroups = fetch.ClearEmptySeminarGroups(seminarGroups)
seminarGroups = fetch.ReplaceEmptyEventNames(seminarGroups)
@@ -120,7 +115,7 @@ func UpdateModulesForCourse(app *pocketbase.PocketBase, course string) error {
//if there are no events in the database, save the new events
if len(events) == 0 {
_, dbError = db.SaveEvents(seminarGroups, collection, app)
_, dbError := db.SaveEvents(seminarGroups, app)
if dbError != nil {
return apis.NewNotFoundError("Events could not be saved", dbError)
}
@@ -146,7 +141,7 @@ func UpdateModulesForCourse(app *pocketbase.PocketBase, course string) error {
}
//save the new events
_, dbError = db.SaveEvents(seminarGroups, collection, app)
_, dbError := db.SaveEvents(seminarGroups, app)
if dbError != nil {
return apis.NewNotFoundError("Events could not be saved", dbError)
}