diff --git a/api/src/parcoursup/infrastructure/repositories/certification-repository.js b/api/src/parcoursup/infrastructure/repositories/certification-repository.js index e4391f7eedd..0b10b1f170e 100644 --- a/api/src/parcoursup/infrastructure/repositories/certification-repository.js +++ b/api/src/parcoursup/infrastructure/repositories/certification-repository.js @@ -1,7 +1,12 @@ +import { datamartKnex } from '../../../../db/knex-database-connection.js'; import { CertificationResult } from '../../domain/read-models/CertificationResult.js'; -const get = ({ ine }) => { - return new CertificationResult({ ine }); +const get = async ({ ine }) => { + const certificationResultDto = await datamartKnex('data_export_parcoursup_certif_result') + .where({ national_student_id: ine }) + .limit(1) + .first(); + return new CertificationResult({ ine: certificationResultDto.national_student_id }); }; export { get }; diff --git a/api/tests/parcoursup/integration/repositories/certification-repository_test.js b/api/tests/parcoursup/integration/repositories/certification-repository_test.js index c95fb303452..d33488eb4ef 100644 --- a/api/tests/parcoursup/integration/repositories/certification-repository_test.js +++ b/api/tests/parcoursup/integration/repositories/certification-repository_test.js @@ -1,5 +1,5 @@ import * as certificationRepository from '../../../../../api/src/parcoursup/infrastructure/repositories/certification-repository.js'; -import { domainBuilder, expect } from '../../../test-helper.js'; +import { datamartBuilder, domainBuilder, expect } from '../../../test-helper.js'; describe('Parcoursup | Infrastructure | Integration | Repositories | certification', function () { describe('#get', function () { @@ -7,11 +7,11 @@ describe('Parcoursup | Infrastructure | Integration | Repositories | certificati it('should return the certification', async function () { // given const ine = '1234'; + datamartBuilder.factory.buildCertificationResult({ nationalStudentId: ine }); + await datamartBuilder.commit(); // when - const result = await certificationRepository.get({ - ine, - }); + const result = await certificationRepository.get({ ine }); // then const expectedCertification = domainBuilder.parcoursup.buildCertificationResult({ ine });