@@ -124,7 +124,7 @@ func EventsByRoom(c *gin.Context) {
124124 room := c .Param ("room" )
125125
126126 var events schema.MultiBuildingEvents [schema.SectionWithTime ]
127- var foundSections [] schema.SectionWithTime
127+ var eventsByRoom schema. RoomEvents [ schema.SectionWithTime ]
128128
129129 // find and parse matching date
130130 err := eventsCollection .FindOne (ctx , bson.M {"date" : date }).Decode (& events )
@@ -143,15 +143,15 @@ func EventsByRoom(c *gin.Context) {
143143 if b .Building == building {
144144 for _ , r := range b .Rooms {
145145 if r .Room == room {
146- foundSections = r . Events
146+ eventsByRoom = r
147147 break
148148 }
149149 }
150150 break
151151 }
152152 }
153153
154- if len ( foundSections ) == 0 {
154+ if eventsByRoom . Room == "" {
155155 c .JSON (http .StatusNotFound , schema.APIResponse [string ]{
156156 Status : http .StatusNotFound ,
157157 Message : "error" ,
@@ -160,7 +160,7 @@ func EventsByRoom(c *gin.Context) {
160160 return
161161 }
162162
163- respond (c , http .StatusOK , "success" , foundSections )
163+ respond (c , http .StatusOK , "success" , eventsByRoom )
164164}
165165
166166// @Id sectionsByRoomDetailed
@@ -222,8 +222,7 @@ func SectionsByRoomDetailed(c *gin.Context) {
222222 }
223223
224224 // Step 3: Fetch full section objects from the sections collection
225- sectionsCollection := configs .GetCollection ("sections" )
226- cursor , err := sectionsCollection .Find (ctx , bson.M {"_id" : bson.M {"$in" : sectionIDs }})
225+ cursor , err := sectionCollection .Find (ctx , bson.M {"_id" : bson.M {"$in" : sectionIDs }})
227226 if err != nil {
228227 respondWithInternalError (c , err )
229228 return
0 commit comments