Merge branch 'feat/send-1-day'
feat(gateway): update Flux query to retrieve data from the last day See merge request team-raclette/project-softweng!16
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
stages:
|
||||
- gateway-build
|
||||
- web-app-build
|
||||
|
||||
include:
|
||||
- local: gateway/.gitlab-ci.yml
|
||||
- local: web-app/.gitlab-ci.yml
|
||||
@@ -5,12 +5,12 @@ default:
|
||||
image: $DOCKER_IMAGE
|
||||
|
||||
stages:
|
||||
- build-docker
|
||||
- gateway-build
|
||||
|
||||
# This job runs only when Dockerfile changes
|
||||
docker-build:
|
||||
gateway-docker-build:
|
||||
image: docker:latest
|
||||
stage: build-docker
|
||||
stage: gateway-build
|
||||
services:
|
||||
- docker:dind
|
||||
script:
|
||||
|
||||
@@ -63,13 +63,12 @@ func (gh *Gateway) requestInflux(c *gin.Context) error {
|
||||
// The Flux query uses a large range (-1000d) and aggregates the latest values.
|
||||
// This ensures we always get the most recent data, even if the database contains old entries.
|
||||
query := fmt.Sprintf(`from(bucket: %q)
|
||||
|> range(start: -1000d)
|
||||
|> range(start: -1d)
|
||||
|> filter(fn: (r) => r["_measurement"] == %q)
|
||||
|> filter(fn: (r) => r["user"] == %q)
|
||||
|> filter(fn: (r) => r["room"] == %q)
|
||||
|> filter(fn: (r) => r["device"] == %q)
|
||||
|> sort(columns: ["_time"], desc: true)
|
||||
|> limit(n: 100)
|
||||
`, INFLUXDB_BUCKET, MEASUREMENT_NAME, user, room, device)
|
||||
results, err := queryAPI.Query(context.Background(), query)
|
||||
if err != nil {
|
||||
|
||||
@@ -5,11 +5,11 @@ default:
|
||||
image: $DOCKER_IMAGE
|
||||
|
||||
stages:
|
||||
- build-docker
|
||||
- web-app-build
|
||||
|
||||
docker-build:
|
||||
web-app-docker-build:
|
||||
image: docker:latest
|
||||
stage: build-docker
|
||||
stage: web-app-build
|
||||
services:
|
||||
- docker:dind
|
||||
script:
|
||||
|
||||
Reference in New Issue
Block a user