From 11ca9dc51f9c21ce05cf76333575e6ec998a92b6 Mon Sep 17 00:00:00 2001 From: Klagarge Date: Sun, 8 Jun 2025 17:52:44 +0200 Subject: [PATCH 1/2] feat(gateway): update Flux query to retrieve data from the last day Signed-off-by: Klagarge --- gateway/src/RequestInflux.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gateway/src/RequestInflux.go b/gateway/src/RequestInflux.go index 0fff1bc..356ef1a 100644 --- a/gateway/src/RequestInflux.go +++ b/gateway/src/RequestInflux.go @@ -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 { From 5bd62c182bb12f9cc10136a40c9e009b15e285e6 Mon Sep 17 00:00:00 2001 From: Klagarge Date: Sun, 8 Jun 2025 18:06:26 +0200 Subject: [PATCH 2/2] ci: refactor CI stages Signed-off-by: Klagarge --- .gitlab-ci.yml | 4 ++++ gateway/.gitlab-ci.yml | 6 +++--- web-app/.gitlab-ci.yml | 6 +++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d4b4dd7..a1eafcd 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,3 +1,7 @@ +stages: + - gateway-build + - web-app-build + include: - local: gateway/.gitlab-ci.yml - local: web-app/.gitlab-ci.yml \ No newline at end of file diff --git a/gateway/.gitlab-ci.yml b/gateway/.gitlab-ci.yml index 9144490..4fddc9d 100644 --- a/gateway/.gitlab-ci.yml +++ b/gateway/.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: diff --git a/web-app/.gitlab-ci.yml b/web-app/.gitlab-ci.yml index d4977c0..e6b3cba 100644 --- a/web-app/.gitlab-ci.yml +++ b/web-app/.gitlab-ci.yml @@ -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: