From e0867cdf84b6276f6f1fbdc3af9924914a26fcaf Mon Sep 17 00:00:00 2001 From: santiago <108626122+marcosantiagomuro@users.noreply.github.com> Date: Thu, 5 Oct 2023 12:04:42 +0200 Subject: [PATCH] test-graph-view | backend now fetches data for graph with this query /way2?dbId=12e920a5-368c-4484-a0a3-e8a626ec49fe&type=KPI --- backend/src/conditions/rc.controller.ts | 8 ++++++++ backend/src/conditions/rc.service.ts | 18 +++++++++++++++++- backend/src/tables.ts | 1 + 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/backend/src/conditions/rc.controller.ts b/backend/src/conditions/rc.controller.ts index e5d5da73..815dbc70 100644 --- a/backend/src/conditions/rc.controller.ts +++ b/backend/src/conditions/rc.controller.ts @@ -23,6 +23,14 @@ export class RCController { return this.service.getWayRoadConditions(wayId, type); } + @Get('way2') + getWay2Conditions( + @Query() query: { dbId: string; type: string }, + ): Promise { + const { dbId, type } = query; + return this.service.getWay2RoadConditions(dbId, type); + } + @Get('') getConditions( @Query() diff --git a/backend/src/conditions/rc.service.ts b/backend/src/conditions/rc.service.ts index 76470506..94a487d2 100644 --- a/backend/src/conditions/rc.service.ts +++ b/backend/src/conditions/rc.service.ts @@ -3,7 +3,13 @@ import { Injectable } from '@nestjs/common'; import { InjectConnection, Knex } from 'nestjs-knex'; import { Condition, LatLngDist, WayId, WaysConditions } from 'src/models'; import groupBy from '../util'; -import { RoadConditions, Ways, ZoomConditions, Conditions2 } from '../tables'; +import { + RoadConditions, + Ways, + ZoomConditions, + Conditions2, + Conditions, +} from '../tables'; import knexPostgis = require('knex-postgis'); @@ -54,6 +60,16 @@ export class RCService { .orderBy('way_dist'); } + async getWay2RoadConditions( + dbId: string, + type: string, + ): Promise { + return Conditions(this.knex_liramap) + .select('fk_way_id', 'type', 'value', 'compute_time') + .where({ type: type, fk_way_id: dbId }) + .orderBy('compute_time'); + } + async getZoomConditions( type: string, zoom: string, diff --git a/backend/src/tables.ts b/backend/src/tables.ts index 59894e68..ad4d7b6d 100644 --- a/backend/src/tables.ts +++ b/backend/src/tables.ts @@ -33,6 +33,7 @@ export const ZoomConditions = (k: Knex) => // ekki@dtu.dk: This is for PostGIS in the LiRAMap (LiraVis) database export interface Condition_Coverage { id: string; + fk_way_id: string; type: string; value: number; section_geom: Geometry;