fixed frontend for new module api endpoint and fixed distinct database request

This commit is contained in:
masterelmar
2023-10-08 21:32:50 +02:00
parent 60eb4e34f6
commit ba2bbf8de9
5 changed files with 10 additions and 8 deletions

View File

@@ -16,7 +16,7 @@ func AddSchedules(app *pocketbase.PocketBase) {
// Every hour update all courses (5 segments - minute, hour, day, month, weekday) "0 * * * *"
// Every three hours update all courses (5 segments - minute, hour, day, month, weekday) "0 */3 * * *"
// Every 10 minutes update all courses (5 segments - minute, hour, day, month, weekday) "*/10 * * * *"
scheduler.MustAdd("updateCourse", "*/30 * * * *", func() {
scheduler.MustAdd("updateCourse", "0 */3 * * *", func() {
courses := events.GetAllCourses(app)

View File

@@ -115,10 +115,10 @@ func GetAllModulesForCourse(app *pocketbase.PocketBase, course string, semester
return events, nil
}
func GetAllModulesDistinct(app *pocketbase.PocketBase) (model.Events, error) {
func GetAllModulesDistinctByNameAndCourse(app *pocketbase.PocketBase) (model.Events, error) {
var events model.Events
err := app.Dao().DB().Select("*").From("events").Distinct(true).All(&events)
err := app.Dao().DB().Select("*").From("events").GroupBy("Name", "course").Distinct(true).All(&events)
if err != nil {
print("Error while getting events from database: ", err)
return nil, err

View File

@@ -28,8 +28,10 @@ func replaceEmptyEntry(modules model.Events, replacement string) {
}
}
// GetAllModulesDistinct returns all modules distinct by name and course from the database
// That means you get all modules with duplicates if they have different courses
func GetAllModulesDistinct(app *pocketbase.PocketBase, c echo.Context) error {
modules, err := db.GetAllModulesDistinct(app)
modules, err := db.GetAllModulesDistinctByNameAndCourse(app)
replaceEmptyEntry(modules, "Sonderveranstaltungen")