Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TECH] Refacto des badges des certifications complémentaires (PIX-9862) #7447

Conversation

aceol
Copy link
Contributor

@aceol aceol commented Nov 13, 2023

🦄 Problème

La table complementary-certification-course-results stocke la clé (partner key) du badge acquis. Ce n’est pas une clé étrangère et ne permet pas de faire aisaiment des jointure. Globalement cela prête à confusion

🤖 Proposition

Supprimer la colonne partnerKey qui se refere au champs key de la table badge et la remplacer par une jointure vers la table complementary-certification-badges

🌈 Remarques

Le juryLevel envoyé par le front pour mettre à jour le resultat du jury passe d'une clé (CLEA) a un ID (10002). Je n'ai pas renommé le champs. ca peut se discuter
La PR est tres grosse, elle pourrait etre decoupée mais ca necessiterais de faire plus de tests func...

💯 Pour tester

  • Creer une session avec une certif droit ou clea et une autre certif edu:
NODE_ENV= npm i [email protected] && LOG_LEVEL=info LOG_FOR_HUMANS=true node ./scripts/data-generation/generate-certif-cli.js 'PRO' 2 '[{"candidateNumber": 1, "key": "CLEA"}, {"candidateNumber": 2, "key": "EDU_2ND_DEGRE"}]'
  • passer la certif avec les 2 candidats
  • finaliser
  • remplir le jury externe pour la certif edu
  • publier

S'assurer que l'on voit bien l'obtention des certifs coté admin et coté user
Ce cas est passé sur la session suivante: https://admin-pr7447.review.pix.fr/sessions/1000015/certifications

@pix-bot-github
Copy link

Une fois les applications déployées, elles seront accessibles via les liens suivants :

Les variables d'environnement seront accessibles via les liens suivants :

@aceol aceol force-pushed the pix-9913-refacto-complementaries branch 3 times, most recently from 3afbf90 to b8d9468 Compare November 13, 2023 22:59
@pix-service-auto-merge pix-service-auto-merge force-pushed the pix-9913-refacto-complementaries branch from 9c4f665 to ee19ef6 Compare November 14, 2023 10:06
Base automatically changed from pix-9913-refacto-complementaries to dev November 14, 2023 10:13
@aceol aceol force-pushed the pix-9862-refacto-complementary-certification-course-results-partnerKey branch 6 times, most recently from a6fff66 to 46c15ce Compare November 17, 2023 08:28
@aceol aceol force-pushed the pix-9862-refacto-complementary-certification-course-results-partnerKey branch 4 times, most recently from eb52bc9 to f396d3c Compare November 22, 2023 14:06
@aceol aceol marked this pull request as ready for review November 23, 2023 08:37
@aceol aceol added 👀 Tech Review Needed 👀 Func Review Needed Need PO validation for this functionally and removed Development in progress labels Nov 23, 2023
@@ -13,7 +13,7 @@ const register = async function (server) {
payload: Joi.object({
data: {
attributes: {
juryLevel: Joi.string().required(),
juryLevel: Joi.required(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Pourquoi le jury level peut être désormais un id ? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

La reponse est vaguement dans les remarque de PR.
Les resultats de certifs comp stockent maintenant non plus une clé de badge mais un id.
On remplace donc ici aussi. On aurait pu choisir de garder la key (mais ca aurait ete un peu etrange), de prendre le level justement (mais il faudrait ensuite retrouver le bon id derriere) ou bien de prendre cet id

Copy link
Contributor

@P-Jeremy P-Jeremy Nov 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Du coup je comprends mieux mais ça serait peut être mieux de renommer la variable, juryLevel en juryLevelComplementaryCertificationBadgeId ou juryComplementaryCertificationBadgeId maintenant

@aceol
Copy link
Contributor Author

aceol commented Nov 23, 2023

Je propose de

  • renommer juryLevel en juryComplementaryCertificationBadgeId (comme suggéré par @P-Jeremy )
  • limiter cette prop via Joi à Number | REJECTED | UNSET

@aceol aceol force-pushed the pix-9862-refacto-complementary-certification-course-results-partnerKey branch from f396d3c to d6a0ece Compare November 23, 2023 19:39
@aceol
Copy link
Contributor Author

aceol commented Nov 24, 2023

Ajout d'un commit pour ajouter un check joi sur le format du JuryLevel
✨ api: Limit juryLevel to id or specific states

@aceol aceol force-pushed the pix-9862-refacto-complementary-certification-course-results-partnerKey branch 2 times, most recently from fac0ad8 to c9ee2b0 Compare November 27, 2023 07:39
@AndreiaPena
Copy link
Member

Vu ensemble: on ne supprime pas la colonne partnerKey de complementary-certification-course-results ici.
A faire dans une autre PR.

@AndreiaPena AndreiaPena added Func Review OK PO validated functionally the PR and removed 👀 Func Review Needed Need PO validation for this functionally labels Nov 27, 2023
.withKeyName('cccresults-ccbadgeId_foreignkey');
});

await knex(TABLE_NAME).update({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pas trop d'inquiétude à se faire niveau perf de cette migration ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a moins de 3000 lignes à mettre à jour, c'est OK

Comment on lines +19 to +20
identifiersType.complementaryCertificationBadgeId,
Joi.string().valid(juryOptions.REJECTED).valid(juryOptions.UNSET),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah oui le juryLevel ça peut soit être un id soit une string dans le cas d'un jury échoué ou en attente ?

static buildFromJuryLevel({ complementaryCertificationCourseId, juryLevel, pixPartnerKey }) {
if (juryLevel === juryOptions.REJECTED) {
static buildFromJuryLevel({ complementaryCertificationCourseId, complementaryCertificationBadgeId, juryLevel }) {
if (juryLevel === 'REJECTED') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question : Je ne sais pas dans quel contexte on se trouve ici mais il n'y a pas un risque d'avoir un juryLevel à UNSET ici et qu'il finisse à la ligne 42 ?

@@ -71,7 +71,7 @@ export { getPrivateCertificate, findPrivateCertificatesByUserId, getShareableCer
async function _getCertifiedBadges(certificationCourseId) {
const complementaryCertificationCourseResults = await knex
.select(
'complementary-certification-course-results.partnerKey',
'badges.key as partnerKey',
Copy link
Member

@AndreiaPena AndreiaPena Nov 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

histoire d'être iso avec le nom de colonne de cette table, mais ça suggère plus de changement dans le code

Suggested change
'badges.key as partnerKey',
'badges.key as key',

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J'ai pas osé (pour limiter les changements effectivement)

@AndreiaPena
Copy link
Member

AndreiaPena commented Nov 27, 2023

Je propose de

  • renommer juryLevel en juryComplementaryCertificationBadgeId (comme suggéré par @P-Jeremy )
  • limiter cette prop via Joi à Number | REJECTED | UNSET

Je suis pas sur pour la proposition dujuryComplementaryCertificationBadgeId Car ce paramètre peut ne pas être une ComplementaryCertificationBadgeId mais REJECTED ou UNSET

@aceol aceol force-pushed the pix-9862-refacto-complementary-certification-course-results-partnerKey branch from c9ee2b0 to de707e7 Compare November 29, 2023 14:48
@pix-service-auto-merge pix-service-auto-merge force-pushed the pix-9862-refacto-complementary-certification-course-results-partnerKey branch 2 times, most recently from 86a621b to bb29a09 Compare November 29, 2023 14:50
@aceol aceol force-pushed the pix-9862-refacto-complementary-certification-course-results-partnerKey branch from bb29a09 to 9bade71 Compare November 29, 2023 15:08
@aceol aceol force-pushed the pix-9862-refacto-complementary-certification-course-results-partnerKey branch from 9bade71 to caafd89 Compare November 29, 2023 15:09
@pix-service-auto-merge pix-service-auto-merge merged commit 07f35de into dev Nov 29, 2023
3 checks passed
@pix-service-auto-merge pix-service-auto-merge deleted the pix-9862-refacto-complementary-certification-course-results-partnerKey branch November 29, 2023 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants