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

[FEATURE] Créer un script pour supprimer des références dans "snapshot" de la table "knowledge-element-snapshots" (PIX-15756) #11231

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

lionelB
Copy link
Member

@lionelB lionelB commented Jan 27, 2025

🥞 Problème

Dans le cadre de la mise en conformité RGPD, on souhaite supprimer les références à userId / assessmentId dans le champ jsonbsnapshot

🥓 Proposition

Faire un script qui supprime les données déjà présentes.

🧃 Remarques

Il faudra faire une 2ieme PR pour arréter d'enregistrer ces données dans les snapshot

😋 Pour tester

  • se connecter sur le postgres avec le CLI scalingo scalingo -a pix-api-review-prxxx pgsql-console
  • lister le contenu des ke select snapshot from "knowledge-element-snapshots"
  • voir les références à userId assessmentId
  • lancer le script en RA avec le CLI scalingo scalingo -a pix-api-review-prxxx run "node scripts/prod/clean-ke-snapshots.js"
  • voir qu'on a plus de références à userId assessmentId select snapshot from "knowledge-element-snapshots"

@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 :

@lionelB lionelB force-pushed the pix-15756/purge-ke-snapshot branch from aa9979d to 0a8d8bb Compare January 28, 2025 07:44
@lionelB lionelB marked this pull request as ready for review January 28, 2025 08:04
@Alexandre-Monney Alexandre-Monney changed the title feat(api): add a script to clean knowledge-element-snapshots [FEATURE] Créer un script pour supprimer des références dans "snapshot" de la table "knowledge-element-snapshots" (PIX-15756) Jan 28, 2025
api/scripts/prod/clean-ke-snapshots.js Outdated Show resolved Hide resolved
api/scripts/prod/clean-ke-snapshots.js Outdated Show resolved Hide resolved
api/scripts/prod/clean-ke-snapshots.js Outdated Show resolved Hide resolved
api/scripts/prod/clean-ke-snapshots.js Show resolved Hide resolved
api/scripts/prod/clean-ke-snapshots.js Show resolved Hide resolved
alicegoarnisson

This comment was marked as outdated.

@alicegoarnisson alicegoarnisson added the team-captains This is your captain speaking label Jan 29, 2025
@lionelB lionelB requested a review from a team January 29, 2025 08:54
@lionelB lionelB force-pushed the pix-15756/purge-ke-snapshot branch from 26d0bdf to 95292f4 Compare January 29, 2025 09:08
@lionelB lionelB force-pushed the pix-15756/purge-ke-snapshot branch from 95292f4 to 95a6177 Compare January 29, 2025 09:17
@HEYGUL
Copy link
Contributor

HEYGUL commented Jan 30, 2025

Je rebondis sur la remarque (Il faudra faire une 2ieme PR pour arréter d'enregistrer ces données dans les snapshot) : ne devrait-on pas d'abord arrêter d'enregistrer avant de nettoyer les données ?

await dependencies.pause(options.pauseDuration);
}
chunkDone += 1;
logInfo(`${chunkDone}/${nbChunk} chunk done ! `);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
logInfo(`${chunkDone}/${nbChunk} chunk done ! `);
logInfo(`${chunkDone}/${nbChunk} chunks done ! `);

.where('id', id)
.update({
// we keep only these property from snapshot
snapshot: JSON.stringify(
Copy link
Contributor

Choose a reason for hiding this comment

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

on a lodash côté backend, on peut simplifier l'écriture avec la fonction pick:

cleanedSnapshot = pick(snapshot, ['source', 'status', 'skillId', 'answerId', 'createdAt', 'earnedPix', 'competenceId'])
...
snapshot: JSON.stringify(cleanedSnapshot)

@lionelB
Copy link
Member Author

lionelB commented Jan 30, 2025

@HEYGUL oui c'est ce qu'il faut qu'on fasse avant pour éviter de relancer plusieurs le script.

.orderBy('id', 'asc');
}
function getKnowlegdeElementSnapshotCount() {
return getKnowlegdeElementSnapshotsQuery().count().first();
Copy link
Member Author

Choose a reason for hiding this comment

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

todo : on aimerait faire un count(1) vu la taille de table

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

.count({ count: 1 }) ce genre d'écriture devrait fonctionner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
👀 Func Review Needed Need PO validation for this functionally 👀 Tech Review Needed team-captains This is your captain speaking team-prescription
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants