mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender.git
synced 2025-08-02 17:59:14 +02:00
fixed frontend for new module api endpoint and fixed distinct database request
This commit is contained in:
@@ -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)
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -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")
|
||||
|
||||
|
Reference in New Issue
Block a user