Skip to content

Commit

Permalink
[TECH] Supprime la colonne partnerKey (PIX-10162 )
Browse files Browse the repository at this point in the history
  • Loading branch information
pix-service-auto-merge authored Dec 15, 2023
2 parents 3f730d5 + 4a95d4e commit eddfcd0
Show file tree
Hide file tree
Showing 32 changed files with 70 additions and 115 deletions.
25 changes: 25 additions & 0 deletions api/db/migrations/20231206185610_drop-column-partner-key.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Make sure you properly test your migration, especially DDL (Data Definition Language)
// ! If the target table is large, and the migration take more than 20 minutes, the deployment will fail !

// You can design and test your migration to avoid this by following this guide
// https://1024pix.atlassian.net/wiki/spaces/DEV/pages/2153512965/Cr+er+une+migration

// If your migrations target `answers` or `knowledge-elements`
// contact @team-captains, because automatic migrations are not active on `pix-datawarehouse-production`
// this may prevent data replication to succeed the day after your migration is deployed on `pix-api-production`
const TABLE_NAME = 'complementary-certification-course-results';
const COLUMN_NAME = 'partnerKey';

const up = async function (knex) {
await knex.schema.table(TABLE_NAME, function (table) {
table.dropColumn(COLUMN_NAME);
});
};

const down = async function (knex) {
await knex.schema.table(TABLE_NAME, (table) => {
table.string(COLUMN_NAME).nullable();
});
};

export { up, down };
9 changes: 5 additions & 4 deletions api/db/seeds/data/common/tooling/session-tooling.js
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,6 @@ async function _makeCandidatesComplementaryCertificationCertifiable(
.select({
badgeId: 'complementary-certification-badges.badgeId',
complementaryCertificationBadgeId: 'complementary-certification-badges.id',
partnerKey: 'badges.key',
campaignId: 'campaigns.id',
})
.join('badges', 'badges.id', 'complementary-certification-badges.badgeId')
Expand All @@ -973,7 +972,6 @@ async function _makeCandidatesComplementaryCertificationCertifiable(
const {
badgeId: selectedBadgeId,
complementaryCertificationBadgeId,
partnerKey,
campaignId,
} = generic.pickOneRandomAmong(badgeAndComplementaryCertificationBadgeIds);

Expand All @@ -998,7 +996,10 @@ async function _makeCandidatesComplementaryCertificationCertifiable(
type: Assessment.types.CAMPAIGN,
campaignParticipationId,
}).id;
certificationCandidate.complementaryCertificationBadgeInfo = { complementaryCertificationBadgeId, partnerKey };
certificationCandidate.complementaryCertificationBadgeInfo = {
complementaryCertificationBadgeId,
badgeId: selectedBadgeId,
};
return { assessmentId, userId: certificationCandidate.userId };
}),
);
Expand Down Expand Up @@ -1108,7 +1109,7 @@ function _makeCandidatesPassCertification({
createdAt: configSession.sessionDate,
}).id;
databaseBuilder.factory.buildComplementaryCertificationCourseResult({
partnerKey: certificationCandidate.complementaryCertificationBadgeInfo.partnerKey,
badgeId: certificationCandidate.complementaryCertificationBadgeInfo.badgeId,
complementaryCertificationBadgeId:
certificationCandidate.complementaryCertificationBadgeInfo.complementaryCertificationBadgeId,
acquired: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ class ComplementaryCertificationScoringWithComplementaryReferential extends Part
constructor({
complementaryCertificationCourseId,
complementaryCertificationBadgeId,
complementaryCertificationBadgeKey,
reproducibilityRate,
hasAcquiredPixCertification,
minimumReproducibilityRate,
} = {}) {
super({
complementaryCertificationCourseId,
complementaryCertificationBadgeId,
partnerKey: complementaryCertificationBadgeKey,
source: ComplementaryCertificationCourseResult.sources.PIX,
});

Expand Down
11 changes: 3 additions & 8 deletions api/lib/domain/read-models/CertifiedBadge.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import _ from 'lodash';

class CertifiedBadge {
constructor({ partnerKey, label, imageUrl, stickerUrl, isTemporaryBadge, message }) {
this.partnerKey = partnerKey;
constructor({ label, imageUrl, stickerUrl, isTemporaryBadge, message }) {
this.label = label;
this.imageUrl = imageUrl;
this.stickerUrl = stickerUrl;
Expand All @@ -18,10 +17,9 @@ class CertifiedBadge {

return Object.values(complementaryCertificationCourseResultsByComplementaryCertificationCourseId)
.map((complementaryCertificationCourseResultsForCourseId) => {
const { partnerKey, label, acquired, hasExternalJury, imageUrl, stickerUrl, certificateMessage } =
const { label, acquired, hasExternalJury, imageUrl, stickerUrl, certificateMessage } =
complementaryCertificationCourseResultsForCourseId[0];
const acquiredCertifiedBadge = {
partnerKey,
label,
imageUrl,
stickerUrl,
Expand Down Expand Up @@ -51,14 +49,12 @@ function _getLowestByLevel(complementaryCertificationCourseResults) {
function _getAcquiredCertifiedBadgesDTOWithExternalJury(complementaryCertificationCourseResults) {
if (complementaryCertificationCourseResults.length === 1) {
const {
partnerKey,
label,
imageUrl,
stickerUrl,
temporaryCertificateMessage: message,
} = complementaryCertificationCourseResults[0];
return new CertifiedBadge({
partnerKey,
label,
imageUrl,
stickerUrl,
Expand All @@ -67,13 +63,12 @@ function _getAcquiredCertifiedBadgesDTOWithExternalJury(complementaryCertificati
});
}

const { partnerKey, label, imageUrl, stickerUrl, certificateMessage, acquired } = _getLowestByLevel(
const { label, imageUrl, stickerUrl, certificateMessage, acquired } = _getLowestByLevel(
complementaryCertificationCourseResults,
);

if (acquired) {
return new CertifiedBadge({
partnerKey,
label,
imageUrl,
stickerUrl,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ export { getPrivateCertificate, findPrivateCertificatesByUserId, getShareableCer
async function _getCertifiedBadges(certificationCourseId) {
const complementaryCertificationCourseResults = await knex
.select(
'badges.key as partnerKey',
'complementary-certification-course-results.source',
'complementary-certification-course-results.acquired',
'complementary-certification-course-results.complementaryCertificationCourseId',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ function _toDomainForCertificationAttestation({ certificationCourseDTO, competen
async function _getCertifiedBadges(certificationCourseId) {
const complementaryCertificationCourseResults = await knex
.select(
'badges.key as partnerKey',
'complementary-certification-course-results.source',
'complementary-certification-course-results.acquired',
'complementary-certification-course-results.complementaryCertificationCourseId',
Expand Down
4 changes: 0 additions & 4 deletions api/tests/acceptance/application/certifications/index_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ describe('Acceptance | API | Certifications', function () {
imageUrl: 'http://tarte.fr/mirabelle.png',
isTemporaryBadge: false,
label: 'tarte à la mirabelle',
partnerKey: 'charlotte_aux_fraises',
stickerUrl: 'http://tarte.fr/sticker.png',
message: 'Miam',
},
Expand Down Expand Up @@ -458,7 +457,6 @@ describe('Acceptance | API | Certifications', function () {
imageUrl: 'http://tarte.fr/mirabelle.png',
isTemporaryBadge: false,
label: 'tarte à la mirabelle',
partnerKey: 'charlotte_aux_fraises',
stickerUrl: 'http://tarte.fr/sticker.png',
message: 'Miam',
},
Expand Down Expand Up @@ -661,7 +659,6 @@ async function _buildDatabaseForV2Certification() {
const cc = databaseBuilder.factory.buildComplementaryCertification();
const ccBadge = databaseBuilder.factory.buildComplementaryCertificationBadge({
complementaryCertificationId: cc.id,
partnerKey: 'charlotte_aux_fraises',
badgeId: badge.id,
imageUrl: 'http://tarte.fr/mirabelle.png',
isTemporaryBadge: false,
Expand Down Expand Up @@ -697,7 +694,6 @@ async function _buildDatabaseForV2Certification() {
databaseBuilder.factory.buildComplementaryCertificationCourseResult({
complementaryCertificationCourseId: id,
complementaryCertificationBadgeId: ccBadge.id,
partnerKey: badge.key,
});
return { userId, session, badge, certificationCourse, assessment, assessmentResult };
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ describe('Acceptance | API | Certifications', function () {
databaseBuilder.factory.buildComplementaryCertificationCourseResult({
complementaryCertificationCourseId: 1234,
complementaryCertificationBadgeId: 24,
partnerKey: badge.key,
source: ComplementaryCertificationCourseResult.sources.PIX,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ describe('Acceptance | Controller | session-controller-get-jury-certification-su
dbf.buildComplementaryCertificationCourseResult({
complementaryCertificationCourseId: id,
complementaryCertificationBadgeId,
partnerKey: badge.key,
acquired: true,
});
asr1 = dbf.buildAssessmentResult.last({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ async function _buildDatabaseForV2Certification({ userId, certificationCourseId
const cc = databaseBuilder.factory.buildComplementaryCertification();
const ccBadge = databaseBuilder.factory.buildComplementaryCertificationBadge({
complementaryCertificationId: cc.id,
partnerKey: 'charlotte_aux_fraises',
badgeId: badge.id,
imageUrl: 'http://tarte.fr/mirabelle.png',
isTemporaryBadge: false,
Expand Down Expand Up @@ -279,7 +278,6 @@ async function _buildDatabaseForV2Certification({ userId, certificationCourseId
databaseBuilder.factory.buildComplementaryCertificationCourseResult({
complementaryCertificationCourseId: id,
complementaryCertificationBadgeId: ccBadge.id,
partnerKey: badge.key,
});
return { userId, session, badge, certificationCourse, assessment, assessmentResult };
}
Original file line number Diff line number Diff line change
Expand Up @@ -383,15 +383,13 @@ describe('Integration | Infrastructure | Repository | Certification', function (
{
isTemporaryBadge: false,
label: 'Pix+ Test 1',
partnerKey: 'PIX_TEST_1',
imageUrl: 'https://images.pix.fr/badge1.svg',
stickerUrl: 'https://images.pix.fr/skicker1.pdf',
message: 'Pix+ Test 1 certificate message',
},
{
isTemporaryBadge: true,
label: 'Pix+ Test 2',
partnerKey: 'PIX_TEST_2',
imageUrl: 'https://images.pix.fr/badge2.svg',
stickerUrl: 'https://images.pix.fr/skicker2.pdf',
message: 'Pix+ Test 2 temporary certificate message',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ describe('Integration | Repository | Certification Course', function () {
complementaryCertificationBadgeId,
}).id;
databaseBuilder.factory.buildComplementaryCertificationCourseResult({
partnerKey: badge.partnerKey,
complementaryCertificationCourseId,
certificationCourseId,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ describe('Integration | Event | Handle Complementary Certifications Scoring', fu
.select()
.first();

expect(_.omit(complementaryCertificationCourseResults, ['id', 'partnerKey'])).to.deep.equal({
expect(_.omit(complementaryCertificationCourseResults, ['id'])).to.deep.equal({
acquired: true,
complementaryCertificationCourseId,
complementaryCertificationBadgeId: 501,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -552,15 +552,13 @@ describe('Integration | Infrastructure | Repository | Certificate_private', func
isTemporaryBadge: false,
label: 'Pix+ test',
message: 'message badge 1',
partnerKey: 'PIX_TEST_1',
},
{
imageUrl: 'https://images.pix.fr/badge2.svg',
stickerUrl: 'https://images.pix.fr/skicker2.pdf',
isTemporaryBadge: true,
label: 'Pix+ test',
message: 'temporary message badge 2',
partnerKey: 'PIX_TEST_2',
},
],
};
Expand Down Expand Up @@ -1005,7 +1003,6 @@ async function _buildValidPrivateCertificateWithAcquiredAndNotAcquiredBadges({
databaseBuilder.factory.buildComplementaryCertificationCourseResult({
complementaryCertificationCourseId,
complementaryCertificationBadgeId: acquiredComplementaryBadgeId,
partnerKey: key,
acquired: true,
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,15 +509,13 @@ describe('Integration | Infrastructure | Repository | Shareable Certificate', fu
isTemporaryBadge: false,
label: 'Pix+ test',
message: 'message badge 1',
partnerKey: 'PIX_TEST_1',
},
{
imageUrl: 'https://images.pix.fr/badge2.svg',
stickerUrl: 'https://images.pix.fr/skicker2.pdf',
isTemporaryBadge: true,
label: 'Pix+ test',
message: 'temporary message badge 2',
partnerKey: 'PIX_TEST_2',
},
],
};
Expand Down Expand Up @@ -660,7 +658,6 @@ async function _buildValidShareableCertificateWithAcquiredBadges({ shareableCert
databaseBuilder.factory.buildComplementaryCertificationCourseResult({
complementaryCertificationCourseId,
complementaryCertificationBadgeId,
partnerKey: key,
acquired: true,
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ describe('Integration | Application | UseCases | certification-results | get-ses
context(`when at least one candidate has passed PIX_EMPLOI_CLEA_V3 certification`, function () {
it(`should return correct csvContent with the PIX_EMPLOI_CLEA_V3 information`, async function () {
// given
const partnerKey = 'PARTNER_KEY';
const expectedHeader = 'Certification skateboard numérique';
const label = 'skateboard numérique';
const session = domainBuilder.buildSession({ id: 777, certificationCenter: 'CentreCertif' });
Expand All @@ -187,7 +186,7 @@ describe('Integration | Application | UseCases | certification-results | get-ses
commentForOrganization: 'RAS',
competencesWithMark: competencesWithMark,
complementaryCertificationCourseResults: [
domainBuilder.buildComplementaryCertificationCourseResult({ partnerKey, acquired: true, label }),
domainBuilder.buildComplementaryCertificationCourseResult({ acquired: true, label }),
],
});

Expand All @@ -207,7 +206,6 @@ describe('Integration | Application | UseCases | certification-results | get-ses

it(`should return a cancelled complementary certification when certification pix is cancelled`, async function () {
// given
const partnerKey = 'PARTNER_KEY';
const expectedHeader = 'Certification skateboard numérique';
const label = 'skateboard numérique';
const session = domainBuilder.buildSession({ id: 777, certificationCenter: 'CentreCertif' });
Expand All @@ -227,7 +225,7 @@ describe('Integration | Application | UseCases | certification-results | get-ses
commentForOrganization: 'RAS',
competencesWithMark: competencesWithMark,
complementaryCertificationCourseResults: [
domainBuilder.buildComplementaryCertificationCourseResult({ partnerKey, acquired: true, label }),
domainBuilder.buildComplementaryCertificationCourseResult({ acquired: true, label }),
],
});

Expand Down Expand Up @@ -268,13 +266,11 @@ describe('Integration | Application | UseCases | certification-results | get-ses
complementaryCertificationCourseResults: [
domainBuilder.buildComplementaryCertificationCourseResult({
id: 1,
partnerKey: '1ST_PARTNER_KEY',
acquired: false,
label: 'Pix+ Bandjo Maître',
}),
domainBuilder.buildComplementaryCertificationCourseResult({
id: 2,
partnerKey: '2ND_PARTNER_KEY',
acquired: true,
label: 'Pix+ Bandjo Expert',
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { ComplementaryCertificationCourseResultForJuryCertification } from '../.

const buildComplementaryCertificationCourseResultForJuryCertification = function ({
id = 1234,
partnerKey = 'PARTNER_KEY',
complementaryCertificationBadgeId = 99,
acquired = true,
label = 'label par défaut',
} = {}) {
return new ComplementaryCertificationCourseResultForJuryCertification({
id,
partnerKey,
complementaryCertificationBadgeId,
acquired,
label,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ import { ComplementaryCertificationCourseResult } from './../../../../lib/domain
const buildComplementaryCertificationCourseResult = function ({
complementaryCertificationCourseId = 2,
complementaryCertificationBadgeId = 2,
partnerKey = 'PARTNER_KEY',
acquired = false,
source = ComplementaryCertificationCourseResult.sources.PIX,
label,
} = {}) {
return new ComplementaryCertificationCourseResult({
complementaryCertificationCourseId,
complementaryCertificationBadgeId,
partnerKey,
acquired,
source,
label,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const buildComplementaryCertificationScoringWithoutComplementaryReferential = fu
complementaryCertificationBadgeId = 60,
certificationCourseId = 42,
reproducibilityRate = 50,
complementaryCertificationBadgeKey = 'badge_key',
pixScore,
minimumEarnedPix,
minimumReproducibilityRate,
Expand All @@ -15,7 +14,6 @@ const buildComplementaryCertificationScoringWithoutComplementaryReferential = fu
complementaryCertificationBadgeId,
certificationCourseId,
reproducibilityRate,
complementaryCertificationBadgeKey,
pixScore,
minimumEarnedPix,
minimumReproducibilityRate,
Expand Down
Loading

0 comments on commit eddfcd0

Please sign in to comment.