diff --git a/db/get-db.http b/db/get-db.http index 446e645..207ef19 100644 --- a/db/get-db.http +++ b/db/get-db.http @@ -13,7 +13,7 @@ GET {{host}}/api/v1/rooms/{{room-id}}/history?window={{window}} Authorization: Basic {{username}} {{password}} ### GET CO2 status of all rooms -GET {{host}}/api/v1/rooms/co2-status +GET {{host}}/api/v1/rooms/high-co2 Authorization: Basic {{username}} {{password}} ### GET all rooms diff --git a/db/src/docs/docs.go b/db/src/docs/docs.go index 0b15831..61d85cb 100644 --- a/db/src/docs/docs.go +++ b/db/src/docs/docs.go @@ -159,21 +159,21 @@ const docTemplate = `{ } } }, - "/rooms/co2-status": { + "/rooms/high-co2": { "get": { "security": [ { "BasicAuth": [] } ], - "description": "Get a list of all rooms with their CO2 status and value", + "description": "Get a list of rooms where CO2 levels are above the threshold", "produces": [ "application/json" ], "tags": [ "rooms" ], - "summary": "Get CO2 status for all rooms", + "summary": "Get rooms with high CO2 levels", "responses": { "200": { "description": "OK", diff --git a/db/src/docs/swagger.json b/db/src/docs/swagger.json index 7227d07..87604b6 100644 --- a/db/src/docs/swagger.json +++ b/db/src/docs/swagger.json @@ -153,21 +153,21 @@ } } }, - "/rooms/co2-status": { + "/rooms/high-co2": { "get": { "security": [ { "BasicAuth": [] } ], - "description": "Get a list of all rooms with their CO2 status and value", + "description": "Get a list of rooms where CO2 levels are above the threshold", "produces": [ "application/json" ], "tags": [ "rooms" ], - "summary": "Get CO2 status for all rooms", + "summary": "Get rooms with high CO2 levels", "responses": { "200": { "description": "OK", diff --git a/db/src/docs/swagger.yaml b/db/src/docs/swagger.yaml index 24d4bb5..b8c0d3d 100644 --- a/db/src/docs/swagger.yaml +++ b/db/src/docs/swagger.yaml @@ -178,9 +178,9 @@ paths: summary: Get history for a room tags: - rooms - /rooms/co2-status: + /rooms/high-co2: get: - description: Get a list of all rooms with their CO2 status and value + description: Get a list of rooms where CO2 levels are above the threshold produces: - application/json responses: @@ -192,7 +192,7 @@ paths: type: array security: - BasicAuth: [] - summary: Get CO2 status for all rooms + summary: Get rooms with high CO2 levels tags: - rooms securityDefinitions: diff --git a/db/src/rest/rest.go b/db/src/rest/rest.go index 54b8e00..5ea05d7 100644 --- a/db/src/rest/rest.go +++ b/db/src/rest/rest.go @@ -107,7 +107,7 @@ func (g *RestGateway) setupRoutes() { v1.GET("/rooms", g.getRooms) v1.GET("/rooms/:room-id/current", g.getRoomCurrent) v1.GET("/rooms/:room-id/history", g.getRoomHistory) - v1.GET("/rooms/co2-status", g.getRoomCO2Status) + v1.GET("/rooms/high-co2", g.getHighCO2Rooms) v1.GET("/export/csv", g.getExportCSV) } @@ -569,22 +569,24 @@ func (g *RestGateway) checkCO2() { } } -// GET /api/v1/rooms/co2-status -// getRoomCO2Status godoc -// @Summary Get CO2 status for all rooms -// @Description Get a list of all rooms with their CO2 status and value +// GET /api/v1/rooms/high-co2 +// getHighCO2Rooms godoc +// @Summary Get rooms with high CO2 levels +// @Description Get a list of rooms where CO2 levels are above the threshold // @Tags rooms // @Produce json // @Success 200 {array} RoomCO2Status // @Security BasicAuth -// @Router /rooms/co2-status [get] -func (g *RestGateway) getRoomCO2Status(c *gin.Context) { +// @Router /rooms/high-co2 [get] +func (g *RestGateway) getHighCO2Rooms(c *gin.Context) { g.statusMu.RLock() defer g.statusMu.RUnlock() - var result []RoomCO2Status + var result = []RoomCO2Status{} for _, status := range g.roomStatus { - result = append(result, *status) + if status.IsHigh { + result = append(result, *status) + } } // Sort by room ID for stability