File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed
Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package controllers
22
33import (
44 "context"
5+ "errors"
56 "net/http"
67 "time"
78
@@ -66,8 +67,13 @@ func AstraEventsByBuilding(c *gin.Context) {
6667 // Find astra event given date
6768 err := astraCollection .FindOne (ctx , bson.M {"date" : date }).Decode (& astra_events )
6869 if err != nil {
69- respondWithInternalError (c , err )
70- return
70+ if errors .Is (err , mongo .ErrNoDocuments ) {
71+ astra_events .Date = date
72+ astra_events .Buildings = []schema.SingleBuildingEvents [schema.AstraEvent ]{}
73+ } else {
74+ respondWithInternalError (c , err )
75+ return
76+ }
7177 }
7278
7379 //parse response for requested building
@@ -115,8 +121,13 @@ func AstraEventsByBuildingAndRoom(c *gin.Context) {
115121 // Find astra event given date
116122 err := astraCollection .FindOne (ctx , bson.M {"date" : date }).Decode (& astra_events )
117123 if err != nil {
118- respondWithInternalError (c , err )
119- return
124+ if errors .Is (err , mongo .ErrNoDocuments ) {
125+ astra_events .Date = date
126+ astra_events .Buildings = []schema.SingleBuildingEvents [schema.AstraEvent ]{}
127+ } else {
128+ respondWithInternalError (c , err )
129+ return
130+ }
120131 }
121132
122133 //parse response for requested building and room
You can’t perform that action at this time.
0 commit comments