mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender.git
synced 2025-08-02 17:59:14 +02:00
Merge branch 'main' into 150-fix-error-response
# Conflicts: # backend/service/addSchedule.go # backend/service/fetch/v2/fetcher.go # frontend/package-lock.json
This commit is contained in:
@@ -127,20 +127,14 @@ func buildIcalQueryForModules(modules []model.FeedCollection) dbx.Expression {
|
||||
|
||||
//second check if modules has only one element
|
||||
if len(modules) == 1 {
|
||||
return dbx.And(
|
||||
dbx.HashExp{"Name": modules[0].Name},
|
||||
dbx.HashExp{"course": modules[0].Course},
|
||||
)
|
||||
return dbx.HashExp{"uuid": modules[0].UUID}
|
||||
}
|
||||
|
||||
//third check if modules has more than one element
|
||||
var wheres []dbx.Expression
|
||||
|
||||
for _, module := range modules {
|
||||
where := dbx.And(
|
||||
dbx.HashExp{"Name": module.Name},
|
||||
dbx.HashExp{"course": module.Course},
|
||||
)
|
||||
where := dbx.HashExp{"uuid": module.UUID}
|
||||
wheres = append(wheres, where)
|
||||
}
|
||||
|
||||
@@ -196,16 +190,16 @@ func GetAllModulesForCourse(app *pocketbase.PocketBase, course string, semester
|
||||
return events, nil
|
||||
}
|
||||
|
||||
func GetAllModulesDistinctByNameAndCourse(app *pocketbase.PocketBase) (model.Events, error) {
|
||||
var events model.Events
|
||||
func GetAllModulesDistinctByNameAndCourse(app *pocketbase.PocketBase) ([]model.ModuleDTO, error) {
|
||||
var modules []model.ModuleDTO
|
||||
|
||||
err := app.Dao().DB().Select("*").From("events").GroupBy("Name").Distinct(true).All(&events)
|
||||
err := app.Dao().DB().Select("Name", "EventType", "Prof", "course", "semester", "uuid").From("events").GroupBy("Name", "Course").Distinct(true).All(&modules)
|
||||
if err != nil {
|
||||
slog.Error("Error while getting events from database: ", err)
|
||||
return nil, fmt.Errorf("error while getting events distinct by name and course from data")
|
||||
}
|
||||
|
||||
return events, nil
|
||||
return modules, nil
|
||||
}
|
||||
|
||||
func DeleteAllEventsForCourse(app *pocketbase.PocketBase, course string, semester string) error {
|
||||
|
Reference in New Issue
Block a user