From 4884c5677f8916961d568e518f9f71220d5727b0 Mon Sep 17 00:00:00 2001 From: "Yassine R." Date: Wed, 13 Dec 2023 16:20:12 +0100 Subject: [PATCH] feat(open-data): add email to data from soliguide --- .talismanrc | 4 +- .../db/dumps/domifa_test.postgres.custom.gz | Bin 91829 -> 91862 bytes ...domifa_test.postgres.restore-data-only.sql | 2 +- ...st.postgres.truncate-restore-data-only.sql | 2 +- .../1701726929874-auto-migration.ts | 26 ------------ .../1701726996834-manual-migration.ts | 22 ---------- .../1701788512483-manual-migration.ts | 39 ------------------ .../1701870413794-auto-migration.ts | 30 -------------- .../1701901668716-auto-migration.ts | 20 --------- .../1702480247859-auto-migration.ts | 15 +++++++ .../OpenDataPlaceTable.typeorm.ts | 3 ++ .../src/open-data-places/load-soliguide.ts | 1 + 12 files changed, 23 insertions(+), 141 deletions(-) delete mode 100644 packages/backend/src/_migrations/1701726929874-auto-migration.ts delete mode 100644 packages/backend/src/_migrations/1701726996834-manual-migration.ts delete mode 100644 packages/backend/src/_migrations/1701788512483-manual-migration.ts delete mode 100644 packages/backend/src/_migrations/1701870413794-auto-migration.ts delete mode 100644 packages/backend/src/_migrations/1701901668716-auto-migration.ts create mode 100644 packages/backend/src/_migrations/1702480247859-auto-migration.ts diff --git a/.talismanrc b/.talismanrc index 4fafdd7977..3a14a7c483 100644 --- a/.talismanrc +++ b/.talismanrc @@ -1,8 +1,8 @@ fileignoreconfig: - filename: _scripts/db/dumps/domifa_test.postgres.restore-data-only.sql - checksum: cc7d142171d74e4ec6fac672fdf444f811db83367028dbe23a4d38196a01fa15 + checksum: fc2c3720259ae183a86581dc71daa2e2762964470d112ec8cc4bb7c83b44bc02 - filename: _scripts/db/dumps/domifa_test.postgres.truncate-restore-data-only.sql - checksum: 4961fa117ae2fd0b34744927341881ac645dd14b68c7b7ade799223080376bba + checksum: cc017bae84047b7761f61da63226cd3e419dc0bdd86264214922d4eeaf4cb5c1 - filename: packages/backend/src/_common/decorators/IsValidPasswordDecorator.ts checksum: f0d4b3cd2e6e2d9b1e0271c34d64adacf87a5f1e7a505402a20869962543608d - filename: packages/backend/src/_migrations/1699910877010-auto-migration.ts diff --git a/_scripts/db/dumps/domifa_test.postgres.custom.gz b/_scripts/db/dumps/domifa_test.postgres.custom.gz index 6cf045d740925ad3359ed030ef6d1c925f8d7d54..478f988d7d7cf102d7c62a69c9ebed01e0cba128 100644 GIT binary patch delta 3076 zcmZWrdstOf7Qg!V4BBda6Ui&=w`Yg*ZF&#vmFf1`2h=dd1gG@ogSL3@= zbDgpgKOd7dUyiPv)A&MsAefS-sUVtQW>Pvrj*Mdiv+vpKGT(f2|2W@ot^HfSwf5TU z>~r^@^}lr1KR#pB$gvrux1(DCarAVs-(c^fpZ5{$eFW`|pW^H;8loZzX1Vh*haxQZ z+f8gNOCbBZIYklRr5+~{8!*tNaZELs8W`zk^Hmi}`wZq-qp-X0366CN#r*}YX$Y`8 z{7D{bh;TWw#Tmd#pn~8CHaBhWXEsI$lf~w;z&HqsdC}=gcEzz@!L+>B&A`++Gbkq5 zTppY2O-BVCT4S@j+gOqyGx2*{ma?*k4@pHVLut}L#0u;hmd^Q#0S{%q9m=*)r8e88 zQk9jRn!)*+44qH?onu`#3ztPg&@)kJD`w|{Xh?td5w{H)MnAv9uNSLJ6%K-!pzc8n@2P%(CoomZ6$SK%TSx0j#z=nS27V(D17xf8!NJ8 z9+>(axnyq5iLpt)v#i?D2R5Pp8{;;^{HgT;Sh08fz%PKWj z&FgTD7=tU*x>nd^?Vc|YXH2$vZ2?cLE6}+hn>hPUF{hMp7n`Zlk{5{U!&gvXmRG>r zga1yG*?mzvDKszlA2#kWbO`IjXz|36wkEooxCtSenX zL~~R53$UeZRyS`$R7Hb;<@0fD3@BfLn2OM`ays`@8FE)ILrgtQQ6v%l=5%w}&Uv1QZ#&cMcK^IJ^(ZB75~epUM5A3|sc|9cUtjM5_?}8hrG{Y{Uli zIxvrTCqR<~hnu}D=2M5<@bSS2PLM>XKBOT*;)Fv-+>m%=01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su^aYb5h6wLFm-9%Bm&7 zzNb1Tr7kltm7Eq288t7Yk$N-?v!cJhIIC%MpY<1K80LU<(iGD3rjlmersh`N6N=h zi$4qNml{@9w&MAVqdq*86F+G4>JRwk^6S4GwzS>o(=&1YoO2J-^Vp%(ll!wbo_)JI zy>;f%TThIV@fXHyYu@)=T77ZLuF`8-b8=9IlO5ijdh(y|dw#!fTua@JoXsUw{YIZ( zCABV6DmtZ { - appLogger.warn("[MIGRATION] Create procuration"); - if ( - domifaConfig().envId === "preprod" || - domifaConfig().envId === "prod" || - domifaConfig().envId === "local" - ) { - await queryRunner.query( - `ALTER TABLE "interactions" ADD "procuration" boolean` - ); - } - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "interactions" DROP COLUMN "procuration"` - ); - } -} diff --git a/packages/backend/src/_migrations/1701726996834-manual-migration.ts b/packages/backend/src/_migrations/1701726996834-manual-migration.ts deleted file mode 100644 index 595cd5b4d7..0000000000 --- a/packages/backend/src/_migrations/1701726996834-manual-migration.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; -import { appLogger } from "../util"; - -export class ManualMigration1701726996834 implements MigrationInterface { - public async up(queryRunner: QueryRunner): Promise { - appLogger.warn("[MIGRATION] Update procuration"); - - const count = await queryRunner.query( - `SELECT count(uuid) from interactions where LOWER(content) LIKE '%courrier remis au mandataire%'` - ); - - console.log(count); - await queryRunner.query( - `UPDATE interactions SET "procuration" = true WHERE LOWER(content) LIKE '%courrier remis au mandataire%';` - ); - } - - // eslint-disable-next-line @typescript-eslint/no-unused-vars - public async down(_queryRunner: QueryRunner): Promise { - // - } -} diff --git a/packages/backend/src/_migrations/1701788512483-manual-migration.ts b/packages/backend/src/_migrations/1701788512483-manual-migration.ts deleted file mode 100644 index d7cec28c9a..0000000000 --- a/packages/backend/src/_migrations/1701788512483-manual-migration.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; -import { interactionRepository, usagerRepository } from "../database"; -import { appLogger } from "../util"; - -export class ManualMigration1701788512483 implements MigrationInterface { - public async up(): Promise { - appLogger.info("[MIGRATION] Update 'napi' for 'VALIDE' usagers"); - const usagers = await usagerRepository - .createQueryBuilder("usager") - .select("uuid, options, decision") - .where( - `(options->'npai'->>'actif')::boolean = true and decision->>'statut' = 'VALIDE'` - ) - .getRawMany(); - - for (const usager of usagers) { - await usagerRepository.update( - { uuid: usager.uuid }, - { - options: { - ...usager.options, - npai: { - actif: false, - dateDebut: null, - }, - }, - } - ); - } - - appLogger.info("[MIGRATION] Delete npai from interactions "); - await interactionRepository.delete({ type: "npai" as any }); - } - - // eslint-disable-next-line @typescript-eslint/no-unused-vars - public async down(_queryRunner: QueryRunner): Promise { - // - } -} diff --git a/packages/backend/src/_migrations/1701870413794-auto-migration.ts b/packages/backend/src/_migrations/1701870413794-auto-migration.ts deleted file mode 100644 index 1c67c4b5c8..0000000000 --- a/packages/backend/src/_migrations/1701870413794-auto-migration.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; -import { domifaConfig } from "../config"; - -export class AutoMigration1701870413794 implements MigrationInterface { - name = "AutoMigration1701870413794"; - - public async up(queryRunner: QueryRunner): Promise { - if ( - domifaConfig().envId === "preprod" || - domifaConfig().envId === "prod" || - domifaConfig().envId === "local" - ) { - await queryRunner.query( - `ALTER TABLE "usager" ALTER COLUMN "lastInteraction" DROP DEFAULT` - ); - await queryRunner.query( - `ALTER TABLE "usager" ALTER COLUMN "options" DROP DEFAULT` - ); - await queryRunner.query( - `CREATE INDEX "IDX_b3d70227bb45dd8060e256ee33" ON "interactions" ("procuration") ` - ); - } - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `DROP INDEX "public"."IDX_b3d70227bb45dd8060e256ee33"` - ); - } -} diff --git a/packages/backend/src/_migrations/1701901668716-auto-migration.ts b/packages/backend/src/_migrations/1701901668716-auto-migration.ts deleted file mode 100644 index b1c2aad20f..0000000000 --- a/packages/backend/src/_migrations/1701901668716-auto-migration.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class AutoMigration1701901668716 implements MigrationInterface { - name = "AutoMigration1701901668716"; - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "structure" ALTER COLUMN "options" SET DEFAULT '{"numeroBoite": true, "surnom": false}'` - ); - await queryRunner.query( - `UPDATE "structure" SET options = jsonb_set(options, '{surnom}', 'false', true)` - ); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "usager" ALTER COLUMN "telephone" SET DEFAULT '{"numero": "", "countryCode": "fr"}'` - ); - } -} diff --git a/packages/backend/src/_migrations/1702480247859-auto-migration.ts b/packages/backend/src/_migrations/1702480247859-auto-migration.ts new file mode 100644 index 0000000000..59ffb1ff61 --- /dev/null +++ b/packages/backend/src/_migrations/1702480247859-auto-migration.ts @@ -0,0 +1,15 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class AutoMigration1702480247859 implements MigrationInterface { + name = "AutoMigration1702480247859"; + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "open_data_places" ADD "mail" text`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE "open_data_places" DROP COLUMN "mail"` + ); + } +} diff --git a/packages/backend/src/database/entities/open-data-place/OpenDataPlaceTable.typeorm.ts b/packages/backend/src/database/entities/open-data-place/OpenDataPlaceTable.typeorm.ts index 4a6e65df36..134fb77986 100644 --- a/packages/backend/src/database/entities/open-data-place/OpenDataPlaceTable.typeorm.ts +++ b/packages/backend/src/database/entities/open-data-place/OpenDataPlaceTable.typeorm.ts @@ -51,6 +51,9 @@ export class OpenDataPlaceTable extends AppTypeormTable { @JoinColumn({ name: "structureId", referencedColumnName: "id" }) structureId: number; + @Column({ type: "text", nullable: true }) + mail: string; + public constructor(entity?: Partial) { super(entity); Object.assign(this, entity); diff --git a/packages/backend/src/open-data-places/load-soliguide.ts b/packages/backend/src/open-data-places/load-soliguide.ts index ad4e1a52ed..4efb5c4449 100644 --- a/packages/backend/src/open-data-places/load-soliguide.ts +++ b/packages/backend/src/open-data-places/load-soliguide.ts @@ -75,6 +75,7 @@ const getFromSoliguide = async () => { longitude: place.position.location.coordinates[0], source: "soliguide", uniqueId: place.lieu_id.toString(), + mail: place?.entity?.mail?.toString(), }) ); }