Skip to content

[TECH] Créer un script permettant l'ajout des ids de contenus formatifs pour la mise en avant en fin de parcours (PIX-24009). - #17410

Open
AndreiaPena wants to merge 1 commit into
devfrom
PIX-24009-create-script-to-set-highlighted-training-ids-on-campaign-with-recommendation-feature-enabled
Open

[TECH] Créer un script permettant l'ajout des ids de contenus formatifs pour la mise en avant en fin de parcours (PIX-24009).#17410
AndreiaPena wants to merge 1 commit into
devfrom
PIX-24009-create-script-to-set-highlighted-training-ids-on-campaign-with-recommendation-feature-enabled

Conversation

@AndreiaPena

@AndreiaPena AndreiaPena commented Sep 7, 2026

Copy link
Copy Markdown
Member

☀️ Problème

Nous avons mis en place la mise en avant dans la page de fin de parcours.
On veut pouvoir permettre au métier de mettre à jours les ids des contenus formatifs (ceux qui seront mis en avant dans la page) pour les campagnes qui bénéficient du moteur de reco.

⛱️ Proposition

Créer un script pour cette mise à jour. Ce script fonctionne en ajoutant les entrées directement dans la ligne de commande.

🏊 Pour tester

Lancer la commande de script

Cas où le script jette une erreur :

  • Oublier un param (campaignId)
node src/prescription/scripts/set-highlighted-trainings-for-campaign.js --highlightedTrainingIds=8004
  • campaignId qui n'existe pas
node src/prescription/scripts/set-highlighted-trainings-for-campaign.js --campaignId=9999999 --highlightedTrainingIds=8004
  • campaignId qui existe (5000), mais pas dans campaign-features
node src/prescription/scripts/set-highlighted-trainings-for-campaign.js --campaignId=5000 --highlightedTrainingIds=8004
  • campaignId qui existe dans campaign-features (112545), mais pas lié à RECOMMENDATION_ENGINE (1012)
node src/prescription/scripts/set-highlighted-trainings-for-campaign.js --campaignId=112545 --highlightedTrainingIds=8004
  • campaignId qui existe dans campaign-features (1000000), lié à RECOMMENDATION_ENGINE (1012) mas le trainingId renseigné n'existe pas
node src/prescription/scripts/set-highlighted-trainings-for-campaign.js --campaignId=1000000 --highlightedTrainingIds=9999999

Cas passant en dryRun

campaignId=1000000 / highlightedTrainingIds = 8001

node src/prescription/scripts/set-highlighted-trainings-for-campaign.js --campaignId=1000000 --highlightedTrainingIds=8001 --dryRun true

=> voir les logs d'info de la prise en compte du trainingId 8001 dans la campaignId 1000000 ET avec le message ROLLBACK: no changes were persisted (dry run)

Lancer en vrai et avoir

Capture d’écran 2026-09-07 à 15 47 25

Tester avec plusieurs ids...

@AndreiaPena AndreiaPena self-assigned this Sep 7, 2026
@AndreiaPena AndreiaPena added the team-devcomp Aka la Brigade du 🪩 Kool and the gang 🪩 label Sep 7, 2026
@AndreiaPena
AndreiaPena requested a review from a team as a code owner September 7, 2026 12:44
@pix-bot-github

pix-bot-github commented Sep 7, 2026

Copy link
Copy Markdown

Co-authored-by: Claude <noreply@anthropic.com>
@AndreiaPena
AndreiaPena force-pushed the PIX-24009-create-script-to-set-highlighted-training-ids-on-campaign-with-recommendation-feature-enabled branch from 506d29e to be6bad1 Compare September 7, 2026 13:51
const foundTrainingIds = foundTrainings.map(({ id }) => id);
const missingTrainingIds = highlightedTrainingIds.filter((trainingId) => !foundTrainingIds.includes(trainingId));
if (missingTrainingIds.length > 0) {
throw new Error(`Training(s) not found in "trainings" table: ${missingTrainingIds.join(', ')}`);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

question: c'est la liste des CF mis en avant manquant, ou des CF en général manquant ?

dryRun: {
type: 'boolean',
describe: 'Run the script without making any database changes',
default: false,

@matthiasferraina matthiasferraina Sep 8, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

suggestion: le mettre à true par defaut

});
});

context('when the campaign has the feature enabled and all training ids exist', function () {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
context('when the campaign has the feature enabled and all training ids exist', function () {
context('when the campaign has the recommandation engine feature enabled, and all provided training ids exist', function () {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team-devcomp Aka la Brigade du 🪩 Kool and the gang 🪩

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants