feat:#16 added room ics api route

This commit is contained in:
Elmar Kresse
2024-10-25 00:16:02 +02:00
parent 3d41d9d6a4
commit 42172fb0a5
13 changed files with 505 additions and 6 deletions

View File

@@ -94,7 +94,7 @@ func GetRoomScheduleForDay(app *pocketbase.PocketBase, room string, date string)
return events, nil
}
func GetRoomSchedule(app *pocketbase.PocketBase, room string, from string, to string) ([]model.Event, error) {
func GetRoomScheduleInTimeSpan(app *pocketbase.PocketBase, room string, from string, to string) ([]model.Event, error) {
var events []model.Event
fromDate, err := time.Parse("2006-01-02", from)
@@ -118,3 +118,17 @@ func GetRoomSchedule(app *pocketbase.PocketBase, room string, from string, to st
}
return events, nil
}
func GetRoomSchedule(app *pocketbase.PocketBase, room string) ([]model.Event, error) {
var events []model.Event
// get all events from event records in the events collection
err := app.Dao().DB().Select("*").From("events").
Where(dbx.Like("Rooms", room).Escape("_", "_")).
GroupBy("Week", "Start", "End", "Rooms").
All(&events)
if err != nil {
return nil, err
}
return events, nil
}