Skip to content

Commit

Permalink
fix: remove truplication
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnaud AMBROSELLI committed Dec 18, 2023
1 parent 2b632a8 commit f15f457
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 660 deletions.
5 changes: 0 additions & 5 deletions .kontinuous/env/prod/templates/dashboard.sealed-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +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_DUPLICATED_1_ID: Ag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9btvMO5HYmD6Upp5vTN2flTSD1vAZ4pwMZ6FStKcyzUsOCVCcQgvydIvndadOD0wO/b5Xs6vmSf3ZClcaMMfvgvjLMHMFInDa3qpwu7RQTfYriKaG1DW/V2ARh7AcyTVMn23vdIdu+qW0B6ZeGOzbRinjUuyR8OINjZIUNFasAeFyW3H3xdKm818IZyvZZE2WUhB9GwedTsA2TcUjNoKnTulniGhKNAq0m3IyHL/2cmi4jkQ/Rq2r/u7/f5XU0ahh2N7jhVTILfka1JeHa75u17P5mBA+19xKi8ivYR7rtfD50NTK+xSJhgLG4gPNgqoZtvjB6hSCXITfylZ2xaknBIerbVwV/9knk2FRrtaF3W3NOZI4fEsaj3kn3e1WcU9hjpwZqcHfaAviaLgCC3qQn5w7px6N23B7SIhbYi9FH94Hg3ggcVTgiidADjHY02+1kfpP6eQVP4yVYvMHak5PehzYwqTzBK4Le+zj0vm8TCL7Ji53GHqV5Ag6FlO6m0PR4Zl/Lv8kcIkMft8zgf3aZWCyKxe6ilZ/6kQ8bDIUewlY=
template:
metadata:
annotations:
Expand Down
15 changes: 0 additions & 15 deletions .kontinuous/env/prod/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,3 @@ jobs:
sentry_auth_token:
secretName: dashboard
secretKey: SENTRY_AUTH_TOKEN
react_app_org_duplicated_1_id:
secretName: dashboard
secretKey: REACT_APP_ORG_DUPLICATED_1_ID
react_app_org_duplicated_1_name:
secretName: dashboard
secretKey: REACT_APP_ORG_DUPLICATED_1_NAME
react_app_org_duplicated_2_id:
secretName: dashboard
secretKey: REACT_APP_ORG_DUPLICATED_2_ID
react_app_org_duplicated_2_name:
secretName: dashboard
secretKey: REACT_APP_ORG_DUPLICATED_2_NAME
react_app_org_id_for_truplication:
secretName: dashboard
secretKey: REACT_APP_ORG_ID_FOR_TRUPLICATION
149 changes: 0 additions & 149 deletions api/src/controllers/migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,155 +89,6 @@ router.put(
}
// End of example of migration.
*/
if (req.params.migrationName === "truplicate-organisations") {
try {
const encryptedItemFields = z.object({
_id: z.string().regex(looseUuidRegex),
organisation: z.string().regex(looseUuidRegex),
createdAt: z.string().regex(isoDateRegex),
updatedAt: z.string().regex(isoDateRegex),
deletedAt: z.string().regex(isoDateRegex).nullable().optional(),
encrypted: z.string(),
encryptedEntityKey: z.string(),
});

const nextOrganisation = z.object({
organisationId: z.string().regex(looseUuidRegex),
teams: z.array(
z.object({
_id: z.string().regex(looseUuidRegex),
name: z.string(),
nightSession: z.boolean(),
organisation: z.string().regex(looseUuidRegex),
})
),
users: z.array(
z.object({
_id: z.string().regex(looseUuidRegex),
email: z.string().email(),
organisation: z.string().regex(looseUuidRegex),
role: z.enum(["admin", "normal", "restricted-access"]),
name: z.string().optional(),
phone: z.string().optional(),
healthcareProfessional: z.boolean().optional(),
})
),
relUserTeams: z.array(
z.object({
_id: z.string().regex(looseUuidRegex),
user: z.string().regex(looseUuidRegex),
team: z.string().regex(looseUuidRegex),
})
),
persons: z.array(encryptedItemFields),
consultations: z.array(encryptedItemFields),
treatments: z.array(encryptedItemFields),
medicalFiles: z.array(encryptedItemFields),
actions: z.array(encryptedItemFields),
groups: z.array(encryptedItemFields),
comments: z.array(encryptedItemFields),
passages: z.array(encryptedItemFields),
rencontres: z.array(encryptedItemFields),
territories: z.array(encryptedItemFields),
observations: z.array(encryptedItemFields),
places: z.array(encryptedItemFields),
relsPersonPlace: z.array(encryptedItemFields),
reports: z.array(encryptedItemFields),
});

nextOrganisation.parse(req.body.organisation1);
nextOrganisation.parse(req.body.organisation2);
} catch (e) {
const error = new Error(`Invalid request in truplicate-organisations: ${e}`);
error.status = 400;
throw error;
}
const saveOrganisation = async (newOrganisation) => {
for (let item of newOrganisation.teams) {
await Team.create(item, { transaction: tx });
}

const password = crypto.randomBytes(60).toString("hex"); // A useless password.,
const forgotPasswordResetExpires = new Date(Date.now() + 60 * 60 * 24 * 30 * 1000); // 30 days
for (let item of newOrganisation.users) {
item.email = item.email.toLocaleLowerCase();
item.forgotPasswordResetToken = crypto.randomBytes(20).toString("hex");
item.forgotPasswordResetExpires = forgotPasswordResetExpires;
item.password = password;
await User.create(item, { transaction: tx });
}

for (let item of newOrganisation.relUserTeams) {
await RelUserTeam.create(item, { transaction: tx });
}

for (let item of newOrganisation.persons) {
await Person.create(item, { transaction: tx });
}

for (let item of newOrganisation.groups) {
await Group.create(item, { transaction: tx });
}

for (let item of newOrganisation.actions) {
await Action.create(item, { transaction: tx });
}

for (let item of newOrganisation.consultations) {
await Consultation.create(item, { transaction: tx });
}

for (let item of newOrganisation.treatments) {
await Treatment.create(item, { transaction: tx });
}

for (let item of newOrganisation.medicalFiles) {
await MedicalFile.create(item, { transaction: tx });
}

for (let item of newOrganisation.comments) {
await Comment.create(item, { transaction: tx });
}

for (let item of newOrganisation.passages) {
await Passage.create(item, { transaction: tx });
}

for (let item of newOrganisation.rencontres) {
await Rencontre.create(item, { transaction: tx });
}

for (let item of newOrganisation.territories) {
await Territory.create(item, { transaction: tx });
}

for (let item of newOrganisation.observations) {
await TerritoryObservation.create(item, { transaction: tx });
}

for (let item of newOrganisation.places) {
await Place.create(item, { transaction: tx });
}

for (let item of newOrganisation.relsPersonPlace) {
await RelPersonPlace.create(item, { transaction: tx });
}

for (let item of newOrganisation.reports) {
await Report.create(item, { transaction: tx });
}
};

const organisation1 = await Organisation.findOne({ where: { _id: req.body.organisation1.organisationId } });
const organisation2 = await Organisation.findOne({ where: { _id: req.body.organisation2.organisationId } });
if (!organisation1 || !organisation2) return res.status(404).send({ ok: false, error: "Not Found" });
await saveOrganisation(req.body.organisation1);
await saveOrganisation(req.body.organisation2);
organisation.set({
migrations: [...(organisation.migrations || []), req.params.migrationName],
migrationLastUpdateAt: new Date(),
});
}

organisation.set({ migrating: false });
await organisation.save({ transaction: tx });
Expand Down
20 changes: 0 additions & 20 deletions dashboard/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +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_duplicated_1_id,uid=1000 \
--mount=type=secret,id=react_app_org_duplicated_1_name,uid=1000 \
--mount=type=secret,id=react_app_org_duplicated_2_id,uid=1000 \
--mount=type=secret,id=react_app_org_duplicated_2_name,uid=1000 \
--mount=type=secret,id=react_app_org_id_for_truplication,uid=1000 \
if [ -f "/run/secrets/react_app_org_duplicated_1_id" ]; then \
export REACT_APP_ORG_DUPLICATED_1_ID=$(cat /run/secrets/react_app_org_duplicated_1_id); \
fi; \
if [ -f "/run/secrets/react_app_org_duplicated_1_name" ]; then \
export REACT_APP_ORG_DUPLICATED_1_NAME=$(cat /run/secrets/react_app_org_duplicated_1_name); \
fi; \
if [ -f "/run/secrets/react_app_org_duplicated_2_id" ]; then \
export REACT_APP_ORG_DUPLICATED_2_ID=$(cat /run/secrets/react_app_org_duplicated_2_id); \
fi; \
if [ -f "/run/secrets/react_app_org_duplicated_2_name" ]; then \
export REACT_APP_ORG_DUPLICATED_2_NAME=$(cat /run/secrets/react_app_org_duplicated_2_name); \
fi; \
if [ -f "/run/secrets/react_app_org_id_for_truplication" ]; then \
export REACT_APP_ORG_ID_FOR_TRUPLICATION=$(cat /run/secrets/react_app_org_id_for_truplication); \
fi; \
yarn build; \
if [ -f "/run/secrets/sentry_auth_token" ]; then \
export SENTRY_AUTH_TOKEN=$(cat /run/secrets/sentry_auth_token); \
Expand Down
Loading

0 comments on commit f15f457

Please sign in to comment.