From 427041cc215498af1b1751675e879c8a5efdefa6 Mon Sep 17 00:00:00 2001 From: alexeh Date: Wed, 20 Mar 2024 12:13:10 +0300 Subject: [PATCH] connect real output, remove carbon_removals from query and set value to 0 --- .../big-query-alerts-query.builder.ts | 4 ++-- .../modules/eudr-alerts/alerts.repository.ts | 20 +++++++++---------- .../dashboard/eudr-dashboard.service.ts | 5 ++--- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/api/src/modules/eudr-alerts/alerts-query-builder/big-query-alerts-query.builder.ts b/api/src/modules/eudr-alerts/alerts-query-builder/big-query-alerts-query.builder.ts index 7978a630b..9af1372eb 100644 --- a/api/src/modules/eudr-alerts/alerts-query-builder/big-query-alerts-query.builder.ts +++ b/api/src/modules/eudr-alerts/alerts-query-builder/big-query-alerts-query.builder.ts @@ -5,9 +5,9 @@ import { GetEUDRAlertsDto } from 'modules/eudr-alerts/dto/get-alerts.dto'; import { EUDRAlertsFields } from 'modules/eudr-alerts/alerts.repository'; export enum EUDR_ALERTS_DATABASE_FIELDS { - alertDate = 'alert_date', + alertDate = 'date', alertConfidence = 'alert_confidence', - alertCount = 'alert_count', + alertCount = 'pixel_count', geoRegionId = 'georegionid', supplierId = 'supplierid', carbonRemovals = 'carbon_removals', diff --git a/api/src/modules/eudr-alerts/alerts.repository.ts b/api/src/modules/eudr-alerts/alerts.repository.ts index ac9019593..762a54690 100644 --- a/api/src/modules/eudr-alerts/alerts.repository.ts +++ b/api/src/modules/eudr-alerts/alerts.repository.ts @@ -26,10 +26,10 @@ import { const projectId: string = 'carto-dw-ac-zk2uhih6'; export enum EUDRAlertsFields { - alertDate = 'alertdate', + alertDate = 'date', alertConfidence = 'alertconfidence', year = 'year', - alertCount = 'alertcount', + alertCount = 'pixel_count', geoRegionId = 'georegionid', supplierId = 'supplierid', } @@ -74,10 +74,10 @@ export class AlertsRepository implements IEUDRAlertsRepository { EUDR_ALERTS_DATABASE_FIELDS.geoRegionId, 'geoRegionId', ); - queryBuilder.addSelect( - EUDR_ALERTS_DATABASE_FIELDS.carbonRemovals, - 'carbonRemovals', - ); + // queryBuilder.addSelect( + // EUDR_ALERTS_DATABASE_FIELDS.carbonRemovals, + // 'carbonRemovals', + // ); queryBuilder.orderBy(EUDR_ALERTS_DATABASE_FIELDS.alertDate, 'ASC'); return this.query(queryBuilder); } @@ -95,10 +95,10 @@ export class AlertsRepository implements IEUDRAlertsRepository { EUDR_ALERTS_DATABASE_FIELDS.supplierId, 'supplierId', ); - queryBuilder.addSelect( - EUDR_ALERTS_DATABASE_FIELDS.carbonRemovals, - 'carbonRemovals', - ); + // queryBuilder.addSelect( + // EUDR_ALERTS_DATABASE_FIELDS.carbonRemovals, + // 'carbonRemovals', + // ); return this.query(queryBuilder); } diff --git a/api/src/modules/eudr-alerts/dashboard/eudr-dashboard.service.ts b/api/src/modules/eudr-alerts/dashboard/eudr-dashboard.service.ts index 9e392e9e2..ae1bcba17 100644 --- a/api/src/modules/eudr-alerts/dashboard/eudr-dashboard.service.ts +++ b/api/src/modules/eudr-alerts/dashboard/eudr-dashboard.service.ts @@ -118,7 +118,7 @@ export class EudrDashboardService { alertMap.get(supplierId)!.geoRegionIdSet.add(geoRegionId); alertMap .get(supplierId)! - .carbonRemovalValuesForSupplier.push(alert.carbonRemovals); + .carbonRemovalValuesForSupplier.push(alert.carbonRemovals ?? 0); }); const allGeoRegions: Record = @@ -595,8 +595,7 @@ export class EudrDashboardService { cur: AlertsOutput, ) => { acc.totalAlerts += cur.alertCount; - acc.totalCarbonRemovals += cur.carbonRemovals; - console.log(cur.geoRegionId); + acc.totalCarbonRemovals += cur.carbonRemovals ?? 0; affectedGeoRegionIds.add(cur.geoRegionId); return acc; },