Skip to content

Commit

Permalink
WIP - generate input data for project calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeh committed Nov 10, 2024
1 parent a8d2e64 commit 43d37c8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 39 deletions.
44 changes: 10 additions & 34 deletions api/src/modules/calculations/calculation.engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { BaseDataView } from '@shared/entities/base-data.view';
import { BaseSize } from '@shared/entities/base-size.entity';
import { BaseIncrease } from '@shared/entities/base-increase.entity';
import { EMISSION_FACTORS_TIER_TYPES } from '@shared/entities/carbon-inputs/emission-factors.entity';
import { CreateCustomProjectDto } from '@api/modules/custom-projects/dto/create-custom-project-dto';

export type GetBaseData = {
countryCode: Country['code'];
Expand Down Expand Up @@ -53,38 +54,13 @@ export class CalculationEngine {
});
}

// buildProject(data: any) {
// const {
// countryCode,
// ecosystem,
// activity,
// activitySubType,
// baseData,
// assumptions,
// plantingSuccessRate,
// sequestrationRateUsed,
// projectSpecificSequestrationRate,
// } = data;
// const carbonPrice = 20;
// const carbonRevenuesToCover = 'Opex';
// const lossRateUsed = 'project-specific';
// const projectSpecificLossRate = 0.001;
// const emissionFactorUsed = EMISSION_FACTORS_TIER_TYPES.TIER_2;
// return new ProjectCalculationBuilder({
// countryCode,
// ecosystem,
// activity,
// activitySubType,
// carbonPrice,
// carbonRevenuesToCover,
// baseData,
// assumptions,
// plantingSuccessRate,
// sequestrationRateUsed,
// projectSpecificSequestrationRate,
// projectSpecificLossRate,
// lossRateUsed,
// emissionFactorUsed,
// });
// }
async generateInput(dto: CreateCustomProjectDto): Promise<any> {
const { countryCode, ecosystem, activity } = dto;
const { baseData, baseSize, baseIncrease, defaultAssumptions } =
await this.getBaseData({
countryCode,
ecosystem,
activity,
});
}
}
12 changes: 7 additions & 5 deletions api/src/modules/custom-projects/custom-projects.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,12 @@ export class CustomProjectsService extends AppBaseService<
);
// TODO: Also define clearly which are the outputs that the consumer expects, that is, relevant for the custom project

return {
estimates: calculator.getCostEstimates(),
summary: calculator.getSummary(),
yearBreakdown: calculator.getYearlyCostBreakdown(),
};
// return {
// estimates: calculator.getCostEstimates(),
// summary: calculator.getSummary(),
// yearBreakdown: calculator.getYearlyCostBreakdown(),
// };

return this.calculationEngine.generateInput(dto);
}
}

0 comments on commit 43d37c8

Please sign in to comment.