feat:#51 added mapping for room schedule request

This commit is contained in:
Elmar Kresse
2024-08-17 18:10:46 +02:00
parent db86ae7206
commit 91d56493c8
7 changed files with 120 additions and 36 deletions

View File

@@ -42,12 +42,25 @@ func GetRoomScheduleForDay(app *pocketbase.PocketBase, room string, date string)
return anonymizedRoomSchedule, nil
}
func GetRoomSchedule(app *pocketbase.PocketBase, room string, from string, to string) ([]model.AnonymizedEventDTO, error) {
func GetRoomSchedule(app *pocketbase.PocketBase, room string, from string, to string, mapped string) ([]model.AnonymizedEventDTO, error) {
if mapped == "true" {
room = functions.MapRoom(room)
}
roomSchedule, err := db.GetRoomSchedule(app, room, from, to)
if err != nil {
return nil, err
}
anonymizedRoomSchedule := anonymizeRooms(roomSchedule)
// If mapped is "true", map the rooms again after anonymization
if mapped == "true" {
for i := range anonymizedRoomSchedule {
anonymizedRoomSchedule[i].Rooms = functions.MapRoom(anonymizedRoomSchedule[i].Rooms)
}
}
return anonymizedRoomSchedule, nil
}