mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender-pwa.git
synced 2025-08-09 05:07:46 +02:00
feat:#22 refactor to cache room schedule and webworker config
This commit is contained in:
@@ -68,16 +68,11 @@ func GetRoomSchedule(app *pocketbase.PocketBase, room string, from string, to st
|
||||
* @return room occupancy list
|
||||
* @return error if the database query fails
|
||||
*/
|
||||
func GetRoomOccupancyList(app *pocketbase.PocketBase, from string, to string, granularity int) (model.RoomOccupancyList, error) {
|
||||
// try parsing the time strings
|
||||
fromTime, err := time.Parse(time.RFC3339, from)
|
||||
if err != nil {
|
||||
return model.RoomOccupancyList{}, err
|
||||
}
|
||||
toTime, err := time.Parse(time.RFC3339, to)
|
||||
if err != nil {
|
||||
return model.RoomOccupancyList{}, err
|
||||
}
|
||||
func GetRoomOccupancyList(app *pocketbase.PocketBase, granularity int) (model.RoomOccupancyList, error) {
|
||||
|
||||
now := time.Now()
|
||||
fromTime := functions.GetSemesterStart(now)
|
||||
toTime := functions.GetSemesterStart(now.AddDate(0, 6, 0))
|
||||
|
||||
// calculate the number of blocks for the given time range and granularity
|
||||
timeDifference := toTime.Sub(fromTime)
|
||||
@@ -142,6 +137,7 @@ func getRelevantRooms(app *pocketbase.PocketBase) ([]string, error) {
|
||||
func emptyRoomOccupancyList(from time.Time, granularity int, blockCount int) model.RoomOccupancyList {
|
||||
return model.RoomOccupancyList{
|
||||
Start: from,
|
||||
Updated: time.Now(),
|
||||
Granularity: granularity,
|
||||
Blocks: blockCount,
|
||||
Rooms: []model.RoomOccupancy{},
|
||||
|
Reference in New Issue
Block a user