Skip to content

Commit

Permalink
fix(api): Return BIGINT for project maximums as numbers are too big a…
Browse files Browse the repository at this point in the history
…nd out of an integer range
  • Loading branch information
alepefe committed Dec 17, 2024
1 parent 6172e8b commit 0f2c4e8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions api/src/modules/projects/projects.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ export class ProjectsService extends AppBaseService<
): Promise<PaginatedProjectsWithMaximums> {
const qb = this.dataSource
.createQueryBuilder()
.select('SUM(abatement_potential)::integer', 'maxAbatementPotential')
.select('SUM(abatement_potential)::BIGINT', 'maxAbatementPotential')
.from(Project, 'project');

const { costRangeSelector } = query;
if (costRangeSelector == COST_TYPE_SELECTOR.NPV) {
qb.addSelect('SUM(capex_npv + opex_npv)::integer', 'maxTotalCost');
qb.addSelect('SUM(capex_npv + opex_npv)::BIGINT', 'maxTotalCost');
} else {
qb.addSelect('SUM(capex + opex)::integer', 'maxTotalCost');
qb.addSelect('SUM(capex + opex)::BIGINT', 'maxTotalCost');
}

const totalsQuery = this.applySearchFiltersToQueryBuilder(qb, query);
Expand Down

0 comments on commit 0f2c4e8

Please sign in to comment.