Skip to content

Commit

Permalink
feat(open-data): add soliguide link
Browse files Browse the repository at this point in the history
  • Loading branch information
pYassine committed Dec 17, 2023
1 parent bbb811c commit cac938a
Show file tree
Hide file tree
Showing 12 changed files with 110 additions and 27 deletions.
6 changes: 4 additions & 2 deletions .talismanrc
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
fileignoreconfig:
- filename: _scripts/db/dumps/domifa_test.postgres.restore-data-only.sql
checksum: fc2c3720259ae183a86581dc71daa2e2762964470d112ec8cc4bb7c83b44bc02
checksum: 40a85fc5e2ee32756348aecf74a0b85754a55959160b84f0dad9dccdba830468
- filename: _scripts/db/dumps/domifa_test.postgres.truncate-restore-data-only.sql
checksum: cc017bae84047b7761f61da63226cd3e419dc0bdd86264214922d4eeaf4cb5c1
checksum: 68720419374aa7549545e234e5097408ac669fb4514d6d0d0fffe20e26bfff55
- filename: packages/backend/src/_common/decorators/IsValidPasswordDecorator.ts
checksum: f0d4b3cd2e6e2d9b1e0271c34d64adacf87a5f1e7a505402a20869962543608d
- filename: packages/backend/src/_migrations/1699910877010-auto-migration.ts
checksum: bd05dd6b68f7fe2ca36ab1180a0449878cf78f4e048d2e5979b3dbe5fba1db53
- filename: packages/backend/src/_migrations/1701870413794-auto-migration.ts
checksum: 281adc67c437b0c3ea874865872dafb0b6a4b23be044694caa6f0d210bbba0f9
- filename: packages/backend/src/_migrations/1702483465656-auto-migration.ts
checksum: 2dbc2450c1df10f68a54897946318976bf8163711f3143e0608ce6c0e7275447
- filename: packages/backend/src/_migrations/_init-db/1603812391580-pr-env-create-database.ts
checksum: 5e9ab65fc62b00a2a2092ccbcf0e2c9fdecefe418452b15b579425774cc1e1e2
- filename: packages/backend/src/_portail-admin/portail-admin-login/portail-admin-login.controller.spec.ts
Expand Down
Binary file modified _scripts/db/dumps/domifa_test.postgres.custom.gz
Binary file not shown.
8 changes: 7 additions & 1 deletion _scripts/db/dumps/domifa_test.postgres.restore-data-only.sql
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,13 @@ COPY public.monitor_batch_process (uuid, "createdAt", "updatedAt", version, "pro
-- Data for Name: open_data_places; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.open_data_places (uuid, "createdAt", "updatedAt", version, nom, adresse, "complementAdresse", ville, "codePostal", departement, region, latitude, longitude, source, "uniqueId", software, "structureId", mail) FROM stdin;
COPY public.open_data_places (uuid, "createdAt", "updatedAt", version, nom, adresse, "complementAdresse", ville, "codePostal", departement, region, latitude, longitude, source, "uniqueId", software, mail, "structureType", "domifaStructureId", "soliguideStructureId") FROM stdin;
2e311da7-5acf-4c4b-844a-49fe237ff60b 2023-12-13 20:22:43.289737+01 2023-12-13 20:22:43.289737+01 1 Structure de Test d'import rue de l import \N Nantes 44000 44 52 47.2139730 -1.5369230 domifa 4 domifa [email protected] \N 4 \N
9a53b6e9-0e58-43d0-bebd-d4f679f6aa74 2023-12-13 20:22:43.302599+01 2023-12-13 20:22:43.302599+01 1 CCAS de Test 1 rue de l ocean \N Asnieres sur seine 92600 92 11 48.9037590 2.2837460 domifa 1 domifa [email protected] \N 1 \N
ad8a4b0a-c5a1-40eb-9f92-220d1e9c548f 2023-12-13 20:22:43.307155+01 2023-12-13 20:22:43.307155+01 1 CCAS de Cayenne 24 avenue louis pasteur \N Cayenne 97300 973 03 4.9434540 -52.3244580 domifa 5 domifa [email protected] \N 5 \N
bb9949ec-206d-4ad6-88a4-1309dec2f2a0 2023-12-13 20:22:43.310765+01 2023-12-13 20:22:43.310765+01 1 Organisme agréé de Test 1 rue du test de l organise agree \N Nantes 44000 44 52 47.2181930 -1.5613680 domifa 3 domifa [email protected] \N 3 \N
3f1db6bf-14d0-48a0-903e-bec13998480d 2023-12-13 20:22:43.313864+01 2023-12-13 20:22:43.313864+01 1 CIAS de Test 2 rue du test \N Pessac 33600 33 75 44.8176020 -0.6129570 domifa 2 domifa [email protected] \N 2 \N
af7254b8-78c7-4760-a821-f8e20b996628 2023-12-13 20:22:44.125163+01 2023-12-13 20:22:44.125163+01 1 ESI La maison du partage 32 rue bouret 75019 paris \N Paris 75019 75 11 48.8817267 2.3742211 soliguide 0 other [email protected] \N \N 0
\.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,13 @@ COPY public.monitor_batch_process (uuid, "createdAt", "updatedAt", version, "pro
-- Data for Name: open_data_places; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.open_data_places (uuid, "createdAt", "updatedAt", version, nom, adresse, "complementAdresse", ville, "codePostal", departement, region, latitude, longitude, source, "uniqueId", software, "structureId", mail) FROM stdin;
COPY public.open_data_places (uuid, "createdAt", "updatedAt", version, nom, adresse, "complementAdresse", ville, "codePostal", departement, region, latitude, longitude, source, "uniqueId", software, mail, "structureType", "domifaStructureId", "soliguideStructureId") FROM stdin;
2e311da7-5acf-4c4b-844a-49fe237ff60b 2023-12-13 20:22:43.289737+01 2023-12-13 20:22:43.289737+01 1 Structure de Test d'import rue de l import \N Nantes 44000 44 52 47.2139730 -1.5369230 domifa 4 domifa [email protected] \N 4 \N
9a53b6e9-0e58-43d0-bebd-d4f679f6aa74 2023-12-13 20:22:43.302599+01 2023-12-13 20:22:43.302599+01 1 CCAS de Test 1 rue de l ocean \N Asnieres sur seine 92600 92 11 48.9037590 2.2837460 domifa 1 domifa [email protected] \N 1 \N
ad8a4b0a-c5a1-40eb-9f92-220d1e9c548f 2023-12-13 20:22:43.307155+01 2023-12-13 20:22:43.307155+01 1 CCAS de Cayenne 24 avenue louis pasteur \N Cayenne 97300 973 03 4.9434540 -52.3244580 domifa 5 domifa [email protected] \N 5 \N
bb9949ec-206d-4ad6-88a4-1309dec2f2a0 2023-12-13 20:22:43.310765+01 2023-12-13 20:22:43.310765+01 1 Organisme agréé de Test 1 rue du test de l organise agree \N Nantes 44000 44 52 47.2181930 -1.5613680 domifa 3 domifa [email protected] \N 3 \N
3f1db6bf-14d0-48a0-903e-bec13998480d 2023-12-13 20:22:43.313864+01 2023-12-13 20:22:43.313864+01 1 CIAS de Test 2 rue du test \N Pessac 33600 33 75 44.8176020 -0.6129570 domifa 2 domifa [email protected] \N 2 \N
af7254b8-78c7-4760-a821-f8e20b996628 2023-12-13 20:22:44.125163+01 2023-12-13 20:22:44.125163+01 1 ESI La maison du partage 32 rue bouret 75019 paris \N Paris 75019 75 11 48.8817267 2.3742211 soliguide 0 other [email protected] \N \N 0
\.
Expand Down
15 changes: 0 additions & 15 deletions packages/backend/src/_migrations/1702480247859-auto-migration.ts

This file was deleted.

67 changes: 67 additions & 0 deletions packages/backend/src/_migrations/1702483465656-auto-migration.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { MigrationInterface, QueryRunner } from "typeorm";
import { domifaConfig } from "../config";

export class AutoMigration1702483465656 implements MigrationInterface {
name = "AutoMigration1702483465656";

public async up(queryRunner: QueryRunner): Promise<void> {
if (
domifaConfig().envId === "preprod" ||
domifaConfig().envId === "prod" ||
domifaConfig().envId === "local"
) {
await queryRunner.query(`ALTER TABLE "open_data_places" ADD "mail" text`);

await queryRunner.query(
`ALTER TABLE "open_data_places" ADD "structureType" text`
);

await queryRunner.query(
`ALTER TABLE "open_data_places" DROP CONSTRAINT "FK_d10ac71fca9180b787ef468659e"`
);
await queryRunner.query(
`DROP INDEX "public"."IDX_d10ac71fca9180b787ef468659"`
);
await queryRunner.query(
`ALTER TABLE "open_data_places" DROP COLUMN "structureId"`
);
await queryRunner.query(
`ALTER TABLE "open_data_places" ADD "domifaStructureId" integer`
);
await queryRunner.query(
`ALTER TABLE "open_data_places" ADD "soliguideStructureId" integer`
);

await queryRunner.query(
`CREATE INDEX "IDX_7ee1e7a8d9441eb76ab7b4aa5a" ON "open_data_places" ("domifaStructureId") `
);
await queryRunner.query(
`ALTER TABLE "open_data_places" ADD CONSTRAINT "FK_7ee1e7a8d9441eb76ab7b4aa5a3" FOREIGN KEY ("domifaStructureId") REFERENCES "structure"("id") ON DELETE CASCADE ON UPDATE NO ACTION`
);
}
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "open_data_places" DROP CONSTRAINT "FK_7ee1e7a8d9441eb76ab7b4aa5a3"`
);
await queryRunner.query(
`DROP INDEX "public"."IDX_7ee1e7a8d9441eb76ab7b4aa5a"`
);

await queryRunner.query(
`ALTER TABLE "open_data_places" DROP COLUMN "soliguideStructureId"`
);
await queryRunner.query(
`ALTER TABLE "open_data_places" DROP COLUMN "domifaStructureId"`
);
await queryRunner.query(
`ALTER TABLE "open_data_places" ADD "structureId" integer`
);
await queryRunner.query(
`CREATE INDEX "IDX_d10ac71fca9180b787ef468659" ON "open_data_places" ("structureId") `
);
await queryRunner.query(
`ALTER TABLE "open_data_places" ADD CONSTRAINT "FK_d10ac71fca9180b787ef468659e" FOREIGN KEY ("structureId") REFERENCES "structure"("id") ON DELETE CASCADE ON UPDATE NO ACTION`
);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Entity, Column, ManyToOne, JoinColumn, Index } from "typeorm";
import { StructureTable } from "../structure";
import { AppTypeormTable } from "../_core";
import { StructureType } from "@domifa/common";

@Entity("open_data_places")
export class OpenDataPlaceTable extends AppTypeormTable<OpenDataPlaceTable> {
Expand Down Expand Up @@ -48,12 +49,18 @@ export class OpenDataPlaceTable extends AppTypeormTable<OpenDataPlaceTable> {
@ManyToOne(() => StructureTable, (structure) => structure.id, {
onDelete: "CASCADE",
})
@JoinColumn({ name: "structureId", referencedColumnName: "id" })
structureId: number;
@JoinColumn({ name: "domifaStructureId", referencedColumnName: "id" })
domifaStructureId: number;

@Column({ type: "integer", nullable: true })
soliguideStructureId: number;

@Column({ type: "text", nullable: true })
mail: string;

@Column({ type: "text", nullable: true })
structureType: StructureType;

public constructor(entity?: Partial<OpenDataPlaceTable>) {
super(entity);
Object.assign(this, entity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ export const openDataPlaceRepository = myDataSource
findExistingPlace: async (latitude: number, longitude: number) => {
return openDataPlaceRepository
.createQueryBuilder("open_data_places")
.select(`nom, ville, "structureId"`)
.select(`nom, ville, "domifaStructureId"`)
.where(
`source='domifa' and ST_DWithin(ST_SetSRID(ST_MakePoint(longitude, latitude), 4326)::geography, ST_SetSRID(ST_MakePoint(:longitude, :latitude), 4326)::geography, 250);`,
`source='domifa' and ST_DWithin(ST_SetSRID(ST_MakePoint(longitude, latitude), 4326)::geography, ST_SetSRID(ST_MakePoint(:longitude, :latitude), 4326)::geography, 400);`,
{
longitude,
latitude,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ export interface OpenDataPlace extends AppEntity {
source: "soliguide" | "domifa" | "data-inclusion";
uniqueId: string; // ID from soliguide | data-inclusion
software: "domifa" | "millesime" | "other";
structureId: number;
domifaStructureId: number;
soliguideStructureId: number;
}
5 changes: 4 additions & 1 deletion packages/backend/src/open-data-places/load-domifa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const loadDomifaData = async () => {
"region",
"latitude",
"longitude",
"email",
"id",
],
});
Expand All @@ -47,7 +48,9 @@ export const loadDomifaData = async () => {
latitude: place.latitude,
longitude: place.longitude,
source: "domifa",
structureId: place.id,
domifaStructureId: place.id,
soliguideStructureId: null,
mail: place.email,
uniqueId: place.id.toString(),
})
);
Expand Down
8 changes: 7 additions & 1 deletion packages/backend/src/open-data-places/load-soliguide.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ const getFromSoliguide = async () => {
source: "soliguide",
uniqueId: place.lieu_id.toString(),
mail: place?.entity?.mail?.toString(),
soliguideStructureId: parseInt(place.lieu_id as any, 10),
})
);
}
Expand All @@ -89,7 +90,12 @@ const getFromSoliguide = async () => {
if (placeExist) {
await openDataPlaceRepository.update(
{ uuid: soliguidePlace.uuid },
{ structureId: placeExist.structureId }
{ domifaStructureId: placeExist.domifaStructureId }
);

await openDataPlaceRepository.update(
{ domifaStructureId: placeExist.domifaStructureId },
{ soliguideStructureId: soliguidePlace.soliguideStructureId }
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/run-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { domifaConfig } from "./config";
server.setTimeout(1000 * 60 * 5);
appLogger.warn(`[${__filename}] Application listening on port 3000`);

if (domifaConfig().envId === "local" && domifaConfig().cron.enable) {
if (domifaConfig().envId === "local") {
await loadDomifaData();
await loadSoliguideData();
// await loadDataInclusionData("CCAS");
Expand Down

0 comments on commit cac938a

Please sign in to comment.