Skip to content

Commit

Permalink
connect real output, remove carbon_removals from query and set value …
Browse files Browse the repository at this point in the history
…to 0
  • Loading branch information
alexeh committed Mar 20, 2024
1 parent 9eab30b commit 427041c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
20 changes: 10 additions & 10 deletions api/src/modules/eudr-alerts/alerts.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string[]> =
Expand Down Expand Up @@ -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;
},
Expand Down

0 comments on commit 427041c

Please sign in to comment.