Skip to content

Commit

Permalink
Remove projectScorecard endpoint and return all info on existing one
Browse files Browse the repository at this point in the history
  • Loading branch information
catalin-oancea committed Dec 18, 2024
1 parent 825cbdb commit c6d2eed
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 46 deletions.
11 changes: 0 additions & 11 deletions api/src/modules/projects/projects.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,6 @@ export class ProjectsController {
async getProject(): ControllerResponse {
return tsRestHandler(
projectsContract.getProject,
async ({ params: { id }, query }) => {
const data = await this.projectsService.getById(id, query);
return { body: { data }, status: HttpStatus.OK };
},
);
}

@TsRestHandler(projectsContract.getProjectWithScorecard)
async getProjectWithScorecard(): ControllerResponse {
return tsRestHandler(
projectsContract.getProjectWithScorecard,
async ({ params: { id }, query }) => {
const data = await this.projectsScorecardService.getById(id, query);
return { body: { data }, status: HttpStatus.OK };
Expand Down
26 changes: 4 additions & 22 deletions api/test/integration/projects/projects.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,8 @@ describe('Projects', () => {
expect(response.status).toBe(HttpStatus.OK);
expect(response.body.data).toHaveLength(2);
expect(response.body.maximums).toEqual({
maxAbatementPotential: 20,
maxTotalCost: 300,
maxAbatementPotential: 30,
maxTotalCost: 200,
});
});

Expand Down Expand Up @@ -387,6 +387,8 @@ describe('Projects', () => {

expect(response.status).toBe(HttpStatus.OK);
expect(response.body.data.projectName).toBe(project.projectName);
expect(response.body.data.feasibilityAnalysisNPV).toBeDefined();
expect(response.body.data.socialFeasibility).toBeDefined();
});

test('Should return a 400 if project does not exist', async () => {
Expand All @@ -396,25 +398,5 @@ describe('Projects', () => {

expect(response.status).toBe(HttpStatus.BAD_REQUEST);
});

test('Should return a project with scorecard', async () => {
const project = await testManager.mocks().createProject();
await testManager.mocks().createProjectScorecard({
id: project.id,
});

const response = await testManager
.request()
.get(
projectsContract.getProjectWithScorecard.path.replace(
':id',
project.id,
),
);

expect(response.status).toBe(HttpStatus.OK);
expect(response.body.data.feasibilityAnalysisNPV).toBeDefined();
expect(response.body.data.socialFeasibility).toBeDefined();
});
});
});
15 changes: 2 additions & 13 deletions shared/contracts/projects.contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,27 +52,16 @@ export const projectsContract = contract.router({
},
query: getProjectScorecardQuerySchema,
},
getProjectWithScorecard: {
method: "GET",
path: "/projects/:id/scorecard",
pathParams: z.object({
id: z.coerce.string().uuid(),
}),
responses: {
200: contract.type<ApiResponse<ProjectScorecardView>>(),
},
query: projectScorecardQuerySchema,
},
getProject: {
method: "GET",
path: "/projects/:id",
pathParams: z.object({
id: z.coerce.string().uuid(),
}),
responses: {
200: contract.type<ApiResponse<Project>>(),
200: contract.type<ApiResponse<ProjectScorecardView>>(),
},
query: projectsQuerySchema,
query: projectScorecardQuerySchema,
},
getProjectCountries: {
method: "GET",
Expand Down

0 comments on commit c6d2eed

Please sign in to comment.