mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender.git
synced 2025-08-01 17:29:14 +02:00
refactoring to clear db functions
This commit is contained in:
@@ -30,6 +30,8 @@ func GetSeminarEvents(c echo.Context, app *pocketbase.PocketBase) error {
|
||||
|
||||
seminarGroups = clearEmptySeminarGroups(seminarGroups)
|
||||
|
||||
seminarGroups = replaceEmptyEventNames(seminarGroups)
|
||||
|
||||
savedRecords, dbError := db.SaveEvents(seminarGroups, collection, app)
|
||||
|
||||
if dbError != nil {
|
||||
@@ -39,6 +41,17 @@ func GetSeminarEvents(c echo.Context, app *pocketbase.PocketBase) error {
|
||||
return c.JSON(http.StatusOK, savedRecords)
|
||||
}
|
||||
|
||||
func replaceEmptyEventNames(groups []model.SeminarGroup) []model.SeminarGroup {
|
||||
for i, group := range groups {
|
||||
for j, event := range group.Events {
|
||||
if event.Name == "" {
|
||||
groups[i].Events[j].Name = "Sonderveranstaltungen"
|
||||
}
|
||||
}
|
||||
}
|
||||
return groups
|
||||
}
|
||||
|
||||
func clearEmptySeminarGroups(seminarGroups []model.SeminarGroup) []model.SeminarGroup {
|
||||
var newSeminarGroups []model.SeminarGroup
|
||||
for _, seminarGroup := range seminarGroups {
|
||||
|
Reference in New Issue
Block a user