Skip to content

Commit

Permalink
fix(backend): add customRef to search column
Browse files Browse the repository at this point in the history
  • Loading branch information
pYassine committed Aug 6, 2024
1 parent 03dad5f commit 8c74a89
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .talismanrc
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ fileignoreconfig:
- filename: packages/backend/src/_migrations/1721817064651-auto-migration.ts
checksum: 4c1f4f912bebc23465a8ed8bf0729091774483f2c15025b60f7cbe7a4cbd0d12
- filename: packages/backend/src/_migrations/1722521444554-auto-migration.ts
checksum: 2ffa61f5f2e5951bd45d22af8e4e37165f05d984e87d5bc1af12e5c23dda6414
checksum: 4a28aeadfff8f388ef4a0ea9709fbb471f9ec931215ffcf28e71a95fc3171e73
- filename: packages/backend/src/_migrations/_init-db/1603812391580-pr-env-create-database.ts
checksum: 1a497f17eb293cae7f347d42c36bb046bbd9e3c8814e16680b3b42f2ae249ccc
checksum: 9c4984cbb8b435b626b2b26fd1cba740542aed18aa568bd03af517651de1aacd
- filename: packages/backend/src/modules/portail-usagers/controllers/portail-usagers-manager/portail-usagers-manager.controller.ts
checksum: 6cb66d899577621ac9f796b2fde88a68263b7422c3f369854d94236c15c0807f
- filename: packages/backend/src/stats/services/publicStats.service.ts
Expand Down
Binary file modified _scripts/db/dumps/domifa_test.postgres.custom.gz
Binary file not shown.
10 changes: 6 additions & 4 deletions packages/backend/src/_migrations/1722521444554-auto-migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,20 @@ export class AutoMigration1722521444554 implements MigrationInterface {
domifaConfig().envId === "local"
) {
await queryRunner.query(
`ALTER TABLE "usager" ADD "nom_prenom" character varying GENERATED ALWAYS AS (LOWER(nom || ' ' || prenom)) STORED NOT NULL`
`ALTER TABLE "usager" ADD "nom_prenom_ref" character varying GENERATED ALWAYS AS (LOWER(nom || ' ' || prenom || ' ' || COALESCE("customRef", ''))) STORED NOT NULL;`
);
await queryRunner.query(
`CREATE INDEX "IDX_3af7a33a589c062bb6151d0969" ON "usager" ("nom_prenom") `
`CREATE INDEX "IDX_3af7a33a589c062bb6151d0969" ON "usager" ("nom_prenom_ref") `
);
}
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "usager" DROP COLUMN "nom_prenom"`);
await queryRunner.query(
`ALTER TABLE "usager" ADD "nom_prenom" character varying NOT NULL`
`ALTER TABLE "usager" DROP COLUMN "nom_prenom_ref"`
);
await queryRunner.query(
`ALTER TABLE "usager" ADD "nom_prenom_ref" character varying NOT NULL`
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -377,12 +377,12 @@ async function createTables(queryRunner: QueryRunner) {
"pinnedNote" jsonb NULL,
nationalite text NULL,
statut text DEFAULT 'INSTRUCTION'::text NOT NULL,
nom_prenom varchar GENERATED ALWAYS AS (lower((nom || ' '::text) || prenom)) STORED NOT NULL,
nom_prenom_ref varchar GENERATED ALWAYS AS (lower((((nom || ' '::text) || prenom) || ' '::text) || COALESCE("customRef", ''::text))) STORED NOT NULL,
CONSTRAINT "PK_1bb36e24229bec446a281573612" PRIMARY KEY (uuid),
CONSTRAINT "UQ_e76056fb098740de66d58a5055a" UNIQUE ("structureId", ref),
CONSTRAINT "FK_a44d882d224e368efdee8eb8c80" FOREIGN KEY ("structureId") REFERENCES public."structure"(id) ON DELETE CASCADE
);
CREATE INDEX "IDX_3af7a33a589c062bb6151d0969" ON public.usager USING btree (nom_prenom);
CREATE INDEX "IDX_3af7a33a589c062bb6151d0969" ON public.usager USING btree (nom_prenom_ref);
CREATE INDEX "IDX_a44d882d224e368efdee8eb8c8" ON public.usager USING btree ("structureId");
CREATE INDEX "IDX_b4d09870ec6cad2d2d98b7cc3a" ON public.usager USING btree (migrated);
CREATE INDEX idx_usager_statut ON public.usager USING btree ("structureId", statut);
Expand Down Expand Up @@ -755,7 +755,6 @@ async function createTables(queryRunner: QueryRunner) {
CREATE INDEX "IDX_ef9fade8e5a6dac06ef5031986" ON public.interactions USING btree (type);
CREATE INDEX "IDX_f9c3ee379ce68d4acfe4199a33" ON public.interactions USING btree ("usagerUUID");
CREATE INDEX idx_interactions_date ON public.interactions USING btree ("structureId", "usagerUUID", "dateInteraction");
CREATE INDEX idx_interactions_type ON public.interactions USING btree ("structureId", "usagerUUID", type);
`
CREATE INDEX idx_interactions_type ON public.interactions USING btree ("structureId", "usagerUUID", type); `
);
}
1 change: 1 addition & 0 deletions packages/backend/src/app.bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export async function bootstrapApplication(): Promise<{
} else {
app.enableCors({
origin: whitelist,
maxAge: 600,
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ export class UsagerTable

@Column({
nullable: false,
name: "nom_prenom",
name: "nom_prenom_ref",
select: false,
})
@Index()
public nom_prenom: string;
public nom_prenom_ref: string;

@Column({ type: "text", nullable: false })
public nom!: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export class UsagersController {
.createQueryBuilder()
.select(joinSelectFields(USAGER_LIGHT_ATTRIBUTES))
.where(
`"structureId" = :structureId and statut = :statut AND nom_prenom ILIKE :search`,
`"structureId" = :structureId and statut = :statut AND nom_prenom_ref ILIKE :search`,
{
statut: "RADIE",
structureId: user.structureId,
Expand Down

0 comments on commit 8c74a89

Please sign in to comment.