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:
|
include:
|
||||||
- local: gateway/.gitlab-ci.yml
|
- local: gateway/.gitlab-ci.yml
|
||||||
- local: web-app/.gitlab-ci.yml
|
- local: web-app/.gitlab-ci.yml
|
||||||
@@ -5,12 +5,12 @@ default:
|
|||||||
image: $DOCKER_IMAGE
|
image: $DOCKER_IMAGE
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- build-docker
|
- gateway-build
|
||||||
|
|
||||||
# This job runs only when Dockerfile changes
|
# This job runs only when Dockerfile changes
|
||||||
docker-build:
|
gateway-docker-build:
|
||||||
image: docker:latest
|
image: docker:latest
|
||||||
stage: build-docker
|
stage: gateway-build
|
||||||
services:
|
services:
|
||||||
- docker:dind
|
- docker:dind
|
||||||
script:
|
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.
|
// 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.
|
// This ensures we always get the most recent data, even if the database contains old entries.
|
||||||
query := fmt.Sprintf(`from(bucket: %q)
|
query := fmt.Sprintf(`from(bucket: %q)
|
||||||
|> range(start: -1000d)
|
|> range(start: -1d)
|
||||||
|> filter(fn: (r) => r["_measurement"] == %q)
|
|> filter(fn: (r) => r["_measurement"] == %q)
|
||||||
|> filter(fn: (r) => r["user"] == %q)
|
|> filter(fn: (r) => r["user"] == %q)
|
||||||
|> filter(fn: (r) => r["room"] == %q)
|
|> filter(fn: (r) => r["room"] == %q)
|
||||||
|> filter(fn: (r) => r["device"] == %q)
|
|> filter(fn: (r) => r["device"] == %q)
|
||||||
|> sort(columns: ["_time"], desc: true)
|
|> sort(columns: ["_time"], desc: true)
|
||||||
|> limit(n: 100)
|
|
||||||
`, INFLUXDB_BUCKET, MEASUREMENT_NAME, user, room, device)
|
`, INFLUXDB_BUCKET, MEASUREMENT_NAME, user, room, device)
|
||||||
results, err := queryAPI.Query(context.Background(), query)
|
results, err := queryAPI.Query(context.Background(), query)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ default:
|
|||||||
image: $DOCKER_IMAGE
|
image: $DOCKER_IMAGE
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- build-docker
|
- web-app-build
|
||||||
|
|
||||||
docker-build:
|
web-app-docker-build:
|
||||||
image: docker:latest
|
image: docker:latest
|
||||||
stage: build-docker
|
stage: web-app-build
|
||||||
services:
|
services:
|
||||||
- docker:dind
|
- docker:dind
|
||||||
script:
|
script:
|
||||||
|
|||||||
Reference in New Issue
Block a user