Skip to content

Commit

Permalink
fix: remove migration consultation team
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnaud AMBROSELLI committed Nov 30, 2023
1 parent fa0f1d0 commit dc6d798
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 113 deletions.
3 changes: 0 additions & 3 deletions .kontinuous/env/prod/templates/dashboard.sealed-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ metadata:
spec:
encryptedData:
SENTRY_AUTH_TOKEN: AgCYmBko6+0bjL94Ok4xU0pQHeE8Ft45OzMHLlxOrK5bSXlwOK67SjFBlWLVcbnv8Hy8N+aUNRxMHD7dhD5yAyEDRWLTJUt6JojLP8f4OkX1hkt4nDI0pubzD5GRQTjLGnfS0mLHB5iIjbWc8gi2fnVx5TblhhmbbcPh8CEH12thKqFnI7TONLs3PVaieT2WTpWE8ZaxokngcERns/cEHJEuf6+744ee0QDgFNeaDxDWsrfcAUCHHo974QaYNhBI2qUxYXPnsiXyynS35f0HDJ3rVwtoQIwQYiM9YzD3BUMxK0evzGl6lciFEsq/69OK0PxFwClBndCyBVcThaKG4ikqgtQUZ1lW8QTdP8jN7k6sU/3sv9g+QkBqEc30YzVqbGjxpt1x5xIIjUu2Ub/NQ1T0KnC98I50DlN/48BWkoepDaWBGZEJ+5hPXwMQ9sF93jvBpF8dti/9Wv1dpcWxKqTNiPqosZ8A+Dt0nP/AVwxji7uLkXX7Df3KDZ0eLamEWO+Lth1a1D2IuYeYQoXk/H/XHvQxBEXKbOmx/g0KiuOMyl1c2pBT/R3A9GNasrV2dI3efcjsaopbtafsbDu5XvSsZt/1A3y4rGW6pEMYh4acr4WrF1X0EXT80n+jLSSCg0M7heMrbrChb4d680V5tPkMfvzNk6D8kVnK/QLmRp/FOjkF300/xR6+41TvbD3cg1z9ONY3N0rRoGp3nP5o1RPXYUQdBvGikOVA6dmUtY7X9SlB0J2MQTEctoabeW630D1vziZ6nV8/ozZn/eH017uu
REACT_APP_ORG_ID_FOR_MIG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bnr2eMyQ0XT/0BnrDoByz9TrWmicJsYFJAah2Hq5c7C+YxT7HeMovRFgSVpdN8LRH0MVhHwx14c24tf9x6T5SWeDLB/8qjdipsuqr8wLmedfLO2nXpuMU4T8Qs74=
template:
metadata:
annotations:
Expand Down
9 changes: 0 additions & 9 deletions .kontinuous/env/prod/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,3 @@ jobs:
sentry_auth_token:
secretName: dashboard
secretKey: SENTRY_AUTH_TOKEN
react_app_org_id_for_migration:
secretName: dashboard
secretKey: REACT_APP_ORG_ID_FOR_MIGRATION
react_app_team_1:
secretName: dashboard
secretKey: REACT_APP_TEAM_1
react_app_team_2:
secretName: dashboard
secretKey: REACT_APP_TEAM_2
19 changes: 0 additions & 19 deletions api/src/controllers/migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,25 +65,6 @@ router.put(
// End of example of migration.
*/

if (req.params.migrationName === "add-team-to-consultation") {
try {
z.array(
z.object({
_id: z.string().regex(looseUuidRegex),
encrypted: z.string(),
encryptedEntityKey: z.string(),
})
).parse(req.body.encryptedConsultationsToUpdate);
} catch (e) {
const error = new Error(`Invalid request in add-team-to-consultation: ${e}`);
error.status = 400;
throw error;
}
for (const { _id, encrypted, encryptedEntityKey } of req.body.encryptedConsultationsToUpdate) {
await Consultation.update({ encrypted, encryptedEntityKey }, { where: { _id }, transaction: tx, paranoid: false });
}
}

organisation.set({ migrating: false });
await organisation.save({ transaction: tx });
});
Expand Down
12 changes: 0 additions & 12 deletions dashboard/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,6 @@ COPY --chown=1000:1000 dashboard/. .
ENV NODE_ENV=production

RUN --mount=type=secret,id=sentry_auth_token,uid=1000 \
--mount=type=secret,id=react_app_org_id_for_migration,uid=1000 \
--mount=type=secret,id=react_app_team_1,uid=1000 \
--mount=type=secret,id=react_app_team_2,uid=1000 \
if [ -f "/run/secrets/react_app_org_id_for_migration" ]; then \
export REACT_APP_ORG_ID_FOR_MIGRATION=$(cat /run/secrets/react_app_org_id_for_migration); \
fi; \
if [ -f "/run/secrets/react_app_team_1" ]; then \
export REACT_APP_TEAM_1=$(cat /run/secrets/react_app_team_1); \
fi; \
if [ -f "/run/secrets/react_app_team_2" ]; then \
export REACT_APP_TEAM_2=$(cat /run/secrets/react_app_team_2); \
fi; \
yarn build; \
if [ -f "/run/secrets/sentry_auth_token" ]; then \
export SENTRY_AUTH_TOKEN=$(cat /run/secrets/sentry_auth_token); \
Expand Down
70 changes: 0 additions & 70 deletions dashboard/src/components/DataMigrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { looseUuidRegex } from '../utils';
import { prepareCommentForEncryption } from '../recoil/comments';
import { prepareGroupForEncryption } from '../recoil/groups';
import { capture } from '../services/sentry';
import { prepareConsultationForEncryption } from '../recoil/consultations';

const LOADING_TEXT = 'Mise à jour des données de votre organisation…';

Expand Down Expand Up @@ -57,75 +56,6 @@ export default function useDataMigrator() {
// End of example of migration.
*/

console.log('mgration', process.env.REACT_APP_ORG_ID_FOR_MIGRATION);
if (organisation._id === process.env.REACT_APP_ORG_ID_FOR_MIGRATION && !organisation.migrations?.includes('add-team-to-consultation')) {
setLoadingText('Ajout des équipes dans vos consultations');
const consultationsRes = await API.get({
path: '/consultation',
query: { organisation: organisationId, after: 0, withDeleted: false },
}).then((res) => res.decryptedData || []);

const consultationsToUpdate = consultationsRes
.filter((c) => !c.teams?.length)
.map((consultation) => {
// do something
switch (consultation.type) {
case 'Médecine générale':
case 'Odontologie':
case 'Ophtalmologie':
case 'Gynécologie':
case 'Social':
case 'Pédiatrie':
case 'Pneumologie':
case 'Cardiologie':
case 'ORL':
case 'IDE':
case 'Psycho CDS':
case 'Accueil / Secrétariat':
case 'Rhumatologie':
case 'Maladies Infectieuses':
case 'Médiateur Covid':
case 'Endocrinologie':
case 'Radiologie':
case 'Psychiatrie':
case 'Psychologique':
case 'Infirmier':
return {
...consultation,
teams: [process.env.REACT_APP_TEAM_1],
};
case 'Perm. Médicale Accueil De Jour':
case 'EMSP SOINS':
case 'EMSP COORDO':
case 'EMSP SOCIAL':
case 'EMSP PERM':
case 'EMSP Psycho':
return {
...consultation,
teams: [process.env.REACT_APP_TEAM_2],
};
default:
capture('Unknown consultation type', { consultation });
return consultation;
}
});

const encryptedConsultationsToUpdate = await Promise.all(
consultationsToUpdate.map(prepareConsultationForEncryption(organisation.consultations)).map(encryptItem)
);
const response = await API.put({
path: `/migration/add-team-to-consultation`,
body: { encryptedConsultationsToUpdate },
query: { migrationLastUpdateAt },
});
if (response.ok) {
setOrganisation(response.organisation);
migrationLastUpdateAt = response.organisation.migrationLastUpdateAt;
} else {
return false;
}
}

return true;
},
};
Expand Down

0 comments on commit dc6d798

Please sign in to comment.