Skip to content

Commit 032f570

Browse files
committed
fix: fix cnll providers
1 parent 90d8435 commit 032f570

File tree

8 files changed

+71
-4
lines changed

8 files changed

+71
-4
lines changed

api/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"start": "yarn db:up && dotenv -e ../.env -- node dist/src/entrypoints/start-api.js",
1919
"job:import": "dotenv -e ../.env -- node dist/src/entrypoints/import.js",
2020
"job:import-from-inner-identifiers": "dotenv -e ../.env -- node dist/src/entrypoints/import-from-inner-identifiers.js",
21+
"job:import-cnll-sill-only": "dotenv -e ../.env -- node dist/src/entrypoints/import-cnll-sill-only-script.js",
2122
"job:update": "dotenv -e ../.env -- node dist/src/entrypoints/update.js",
2223
"update-then-wait": "./update-then-wait.sh",
2324
"_format": "prettier \"**/*.{ts,tsx,json,md}\"",

api/src/core/adapters/CNLL/getExternalData.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,21 @@ export const getCNLLSoftwareExternalData: GetSoftwareExternalData = memoize(
3232
);
3333

3434
const cnllProviderToCMProdivers = (provider: CnllPrestatairesSill.Prestataire): SchemaOrganization => {
35+
const cnllId = provider.url.split("/").at(-1) ?? provider.nom;
36+
3537
return {
3638
"@type": "Organization" as const,
3739
name: provider.nom,
38-
url: provider.url ?? undefined,
3940
identifiers: [
41+
...(provider.url
42+
? [
43+
identifersUtils.makeCNLLIdentifier({
44+
cNNLId: cnllId,
45+
url: provider.url,
46+
additionalType: "Organization"
47+
})
48+
]
49+
: []),
4050
identifersUtils.makeSIRENIdentifier({
4151
SIREN: provider.siren,
4252
additionalType: "Organization"
@@ -71,5 +81,5 @@ const formatCNLLProvidersToExternalData = (
7181
cNNLId: cnllProdivers.sill_id.toString()
7282
})
7383
],
74-
providers: cnllProdivers.prestataires.map(prodiver => cnllProviderToCMProdivers(prodiver))
84+
providers: cnllProdivers.prestataires.map(cnllProviderToCMProdivers)
7585
});

api/src/core/adapters/comptoirDuLibre/getCDLExternalData.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,6 @@ const formatCDLSoftwareToExternalData = (
107107
]
108108
: [])
109109
],
110-
providers: cdlSoftwareItem.providers.map(prodiver => cdlProviderToCMProdivers(prodiver))
110+
providers: cdlSoftwareItem.providers.map(cdlProviderToCMProdivers)
111111
};
112112
};

api/src/core/adapters/wikidata/getWikidataSoftware.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,8 @@ export async function fetchEntity(wikidataId: string): Promise<{ entity: Wikidat
350350

351351
const entity = Object.values(json["entities"])[0] as WikidataEntity;
352352

353+
console.info(` -> fetched wiki soft : ${entity.aliases.en?.[0]?.value || entity.aliases.fr?.[0]?.value}`);
354+
353355
return { entity };
354356
}
355357

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// SPDX-FileCopyrightText: 2021-2025 DINUM <[email protected]>
2+
// SPDX-FileCopyrightText: 2024-2025 Université Grenoble Alpes
3+
// SPDX-License-Identifier: MIT
4+
5+
// Note this is temporary script, to use as long CNLL doesn't have a proper API providing their own identifiers
6+
// Do not use this script outside of the main SILL application
7+
8+
import { Kysely } from "kysely";
9+
import { getDbApiAndInitializeCache } from "../core/adapters/dbApi/kysely/createPgDbApi";
10+
import { Database } from "../core/adapters/dbApi/kysely/kysely.database";
11+
import { createPgDialect } from "../core/adapters/dbApi/kysely/kysely.dialect";
12+
import { env } from "../env";
13+
import { importCnllSillOnly } from "../rpc/import-cnll-sill-only";
14+
15+
const kyselyDb = new Kysely<Database>({ dialect: createPgDialect(env.databaseUrl) });
16+
17+
const { dbApi } = getDbApiAndInitializeCache({
18+
"dbKind": "kysely",
19+
"kyselyDb": kyselyDb
20+
});
21+
22+
importCnllSillOnly(dbApi)
23+
.then(() => console.log("Import CNLL (SILL only script) - Done"))
24+
.catch(console.error);
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// SPDX-FileCopyrightText: 2021-2025 DINUM <[email protected]>
2+
// SPDX-FileCopyrightText: 2024-2025 Université Grenoble Alpes
3+
// SPDX-License-Identifier: MIT
4+
5+
// Note this is temporary script, to use as long CNLL doesn't have a proper API providing their own identifiers
6+
// Do not use this script outside of the main SILL application
7+
8+
import { getCnllPrestatairesSill } from "../core/adapters/getCnllPrestatairesSill";
9+
import { DbApiV2 } from "../core/ports/DbApiV2";
10+
11+
export const importCnllSillOnly = async (dbApi: DbApiV2): Promise<void> => {
12+
const cnllSource = await dbApi.source.getByName({ name: "cnll" });
13+
14+
if (!cnllSource || cnllSource.kind !== "CNLL") {
15+
console.warn(`This source if not compatible with CNLL Adapter : ${JSON.stringify(cnllSource, null, 2)}`);
16+
return;
17+
}
18+
19+
const cnllProviders = await getCnllPrestatairesSill();
20+
21+
const toInsert = cnllProviders.map(provider => ({
22+
sourceSlug: cnllSource.slug,
23+
externalId: provider.sill_id.toString(),
24+
softwareId: provider.sill_id
25+
}));
26+
27+
await dbApi.softwareExternalData.saveIds(toInsert);
28+
};

api/update-then-wait.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ START_DATETIME=$(date "+%Y-%m-%d %H:%M:%S")
1616

1717
echo "Starting update at ${START_DATETIME}"
1818
# Run the update command
19+
yarn job:import-from-inner-identifiers
20+
yarn job:import-cnll-sill-only
1921
yarn job:update
2022

2123
END_DATETIME=$(date "+%Y-%m-%d %H:%M:%S")

web/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<link rel="shortcut icon" href="/dsfr/favicon/favicon.ico" type="image/x-icon" />
1616
<link rel="manifest" href="/dsfr/favicon/manifest.webmanifest" crossorigin="use-credentials" />
1717

18-
<link rel="stylesheet" href="/dsfr/utility/icons/icons.min.css?hash=bdc4ebf9" />
18+
<link rel="stylesheet" href="/dsfr/utility/icons/icons.min.css?hash=a1396dfb" />
1919
<link rel="stylesheet" href="/dsfr/dsfr.min.css" />
2020

2121
%VITE_HEAD%

0 commit comments

Comments
 (0)