Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#124 improve UI with new fields #190

Merged
merged 41 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
02e9855
See #168 : improve documentation
guillermau Nov 12, 2024
cf653ad
Fix #168 : a small mistake
guillermau Nov 12, 2024
85fd566
see #160 : remove the not null on addedByAgentId
guillermau Nov 12, 2024
58f219c
see #160 : featch all data from HAL
guillermau Nov 12, 2024
6692c03
see #160 : filter by software which have swhidId and handle parse error
guillermau Nov 13, 2024
f5e4246
See #166 : import more data into DB
guillermau Nov 18, 2024
c30250a
Merge remote-tracking branch 'origin/main' into #160-automated-import
guillermau Nov 18, 2024
2b332f8
see #160 : revert agentId allowed to null
guillermau Nov 18, 2024
4e6df3f
see #160 : add agent id init or get
guillermau Nov 18, 2024
9eecfb5
se #160 : improve request on db
guillermau Nov 18, 2024
9c9800c
see #160 : improve style
guillermau Nov 18, 2024
6ea7bfa
Improve dev env
guillermau Nov 18, 2024
8919db8
Merge remote-tracking branch 'origin/main' into #166-importe-more-dat…
guillermau Nov 18, 2024
15fec3f
see #160 : revert agentId allowed to null
guillermau Nov 18, 2024
a0d5ba1
see #160 : add agent id init or get
guillermau Nov 18, 2024
9865eb0
se #160 : improve request on db
guillermau Nov 18, 2024
1fdb4c1
see #160 : improve style
guillermau Nov 18, 2024
7b15706
see #166 : retrieve and map data
guillermau Nov 18, 2024
f19a92b
see #166 : fix tests
guillermau Nov 19, 2024
f950085
see #166 : fix tests
guillermau Nov 19, 2024
f43f26d
see #166 : Import as array
guillermau Nov 19, 2024
9c96231
#166 : load new env conf in sh
guillermau Nov 20, 2024
833d4b2
#160 : fix syle
guillermau Nov 20, 2024
bf3b7c8
#160 : change the way to load config
guillermau Nov 20, 2024
6f1aa10
Merge branch '#160-automated-import' into #166-importe-more-data-from…
guillermau Nov 20, 2024
33eaf7e
#166 Fix test
guillermau Nov 20, 2024
2218a22
#166 : present date of the version
guillermau Nov 20, 2024
30d285b
see #166 : fix date from wikidata and tests
guillermau Nov 21, 2024
e7b02fa
see #124 : fix catalog view
guillermau Nov 21, 2024
39bd410
see #124 : present domains and sofware languages
guillermau Nov 20, 2024
28e6003
see #124 : remove blank fields
guillermau Nov 21, 2024
aedd024
see #160 : Fix naming
guillermau Nov 22, 2024
71e1572
#166 : fix naming and type
guillermau Nov 22, 2024
0ebf7a8
Merge branch 'main' into #124-improve-ui-with-new-fields
guillermau Nov 22, 2024
271eff4
fix names
guillermau Nov 22, 2024
5bd2a1f
Hide last date if no date
guillermau Nov 22, 2024
d4645f8
Fix naming in I18
guillermau Nov 22, 2024
b5e7a2c
fix format
guillermau Nov 22, 2024
ee7b983
Fix type
guillermau Nov 22, 2024
80e91ba
Fix version on wikidata not found
guillermau Nov 22, 2024
6fcb484
Merge remote-tracking branch 'origin/196-ne-plus-gérer-lédition-des-u…
guillermau Nov 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ node_modules
.env
deploy_sill.js
docker-data
.dev
.bruno
4 changes: 3 additions & 1 deletion api/.env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ export CONFIGURATION=$(cat << EOF
"githubWebhookSecret": "$SILL_WEBHOOK_SECRET",
"port": $SILL_API_PORT,
"isDevEnvironnement": $SILL_IS_DEV_ENVIRONNEMENT,
"externalSoftwareDataOrigin": $SILL_EXTERNAL_SOFTWARE_DATA_ORIGIN
"externalSoftwareDataOrigin": $SILL_EXTERNAL_SOFTWARE_DATA_ORIGIN,
"initializeSoftwareFromSource": $INITSOFTFROMSOURCE,
"botAgentEmail": $BOTAGENTEMAIL,
}
EOF
)
Expand Down
4 changes: 3 additions & 1 deletion api/scripts/compile-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ import { env } from "../src/env";
"githubPersonalAccessTokenForApiRateLimit": env.githubPersonalAccessTokenForApiRateLimit,
"doPerPerformPeriodicalCompilation": false,
"doPerformCacheInitialization": false,
"externalSoftwareDataOrigin": env.externalSoftwareDataOrigin
"externalSoftwareDataOrigin": env.externalSoftwareDataOrigin,
"initializeSoftwareFromSource": env.initializeSoftwareFromSource,
"botAgentEmail": env.botAgentEmail
});

await useCases.fetchAndSaveExternalDataForAllSoftwares();
Expand Down
2 changes: 1 addition & 1 deletion api/scripts/migration/software.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const zSoftwareRow = z.object({
"license": z.string(),
"softwareType": zSoftwareType,
"catalogNumeriqueGouvFrId": z.string().optional(),
"versionMin": z.string(),
"versionMin": z.string().optional(),
"workshopUrls": z.array(z.string()),
"testUrls": z.array(
z.object({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ export const createPgSoftwareExternalDataRepository = (db: Kysely<Database>): So
...softwareExternalData,
developers: JSON.stringify(softwareExternalData.developers),
label: JSON.stringify(softwareExternalData.label),
keywords: JSON.stringify(softwareExternalData.keywords),
applicationCategory: JSON.stringify(softwareExternalData.applicationCategory),
programmingLanguage: JSON.stringify(softwareExternalData.programmingLanguage),
description: JSON.stringify(softwareExternalData.description)
};

Expand Down
30 changes: 26 additions & 4 deletions api/src/core/adapters/dbApi/kysely/createPgSoftwareRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const createPgSoftwareRepository = (db: Kysely<Database>): SoftwareReposi
.executeTakeFirstOrThrow();

console.log(
`inserted software correctly, softwareId is : ${softwareId}, about to insert similars : `,
`inserted software correctly, softwareId is : ${softwareId} (${softwareName}), about to insert similars : `,
similarSoftwareExternalDataIds
);

Expand Down Expand Up @@ -178,7 +178,8 @@ export const createPgSoftwareRepository = (db: Kysely<Database>): SoftwareReposi
documentationUrl: softwareExternalData?.documentationUrl,
comptoirDuLibreServiceProviderCount: software.comptoirDuLibreSoftware?.providers.length ?? 0,
testUrl: testUrls[0]?.url,
parentWikidataSoftware: parentExternalData
parentWikidataSoftware: parentExternalData,
keywords: software?.keywords ?? softwareExternalData?.keywords ?? []
});
}),
getById: getBySoftwareId,
Expand Down Expand Up @@ -222,6 +223,16 @@ export const createPgSoftwareRepository = (db: Kysely<Database>): SoftwareReposi

return builder.execute().then(async softwares => {
const userAndReferentCountByOrganization = await getUserAndReferentCountByOrganizationBySoftwareId(db);
const dateParser = (str: string | Date | undefined | null) => {
if (str && typeof str === "string") {
const date = new Date(str);
return date.valueOf();
} else if (str && str instanceof Date) {
return str.valueOf();
} else {
return undefined;
}
};
return softwares.map(
({
testUrls,
Expand All @@ -248,6 +259,10 @@ export const createPgSoftwareRepository = (db: Kysely<Database>): SoftwareReposi
// isInSill: true // TODO: check if this is true
// })
// ) ?? [],
latestVersion: software.latestVersion ?? {
semVer: softwareExternalData?.softwareVersion ?? "",
publicationTime: dateParser(softwareExternalData.publicationTime)
},
userAndReferentCountByOrganization:
userAndReferentCountByOrganization[software.softwareId] ?? {},
authors: (softwareExternalData?.developers ?? []).map(dev => ({
Expand All @@ -266,7 +281,9 @@ export const createPgSoftwareRepository = (db: Kysely<Database>): SoftwareReposi
comptoirDuLibreServiceProviderCount:
software.comptoirDuLibreSoftware?.providers.length ?? 0,
testUrl: testUrls[0]?.url,
parentWikidataSoftware: parentExternalData ?? undefined
parentWikidataSoftware: parentExternalData ?? undefined,
applicationCategory: softwareExternalData?.applicationCategory ?? [],
programmingLanguage: softwareExternalData?.programmingLanguage ?? []
});
}
);
Expand Down Expand Up @@ -398,7 +415,12 @@ const makeGetSoftwareBuilder = (db: Kysely<Database>) =>
framaLibreId: ref("ext.framaLibreId"),
websiteUrl: ref("ext.websiteUrl"),
sourceUrl: ref("ext.sourceUrl"),
documentationUrl: ref("ext.documentationUrl")
documentationUrl: ref("ext.documentationUrl"),
programmingLanguage: ref("ext.programmingLanguage"),
applicationCategory: ref("ext.applicationCategory"),
keywords: ref("ext.keywords"),
softwareVersion: ref("ext.softwareVersion"),
publicationTime: ref("ext.publicationTime")
}).as("softwareExternalData"),
({ ref, fn }) =>
fn
Expand Down
7 changes: 6 additions & 1 deletion api/src/core/adapters/dbApi/kysely/kysely.database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ type SoftwareExternalDatasTable = {
sourceUrl: string | null;
documentationUrl: string | null;
license: string | null;
softwareVersion: string | null;
keywords: JSONColumnType<string[]> | null;
programmingLanguage: JSONColumnType<string[]> | null;
applicationCategory: JSONColumnType<string[]> | null;
publicationTime: Date | null;
};

type SoftwareType =
Expand Down Expand Up @@ -110,7 +115,7 @@ type SoftwaresTable = {
license: string;
softwareType: JSONColumnType<SoftwareType>;
catalogNumeriqueGouvFrId: string | null;
versionMin: string;
versionMin: string | null;
workshopUrls: JSONColumnType<string[]>;
testUrls: JSONColumnType<
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Kysely } from "kysely";

export async function up(db: Kysely<any>): Promise<void> {
await db.schema
.alterTable("softwares")
.alterColumn("versionMin", ac => ac.dropNotNull())
.execute();

await db.schema
.alterTable("software_external_datas")
.addColumn("softwareVersion", "text")
.addColumn("publicationTime", "date")
.addColumn("keywords", "jsonb")
.addColumn("programmingLanguage", "jsonb")
.addColumn("applicationCategory", "jsonb")
.execute();
}

export async function down(db: Kysely<any>): Promise<void> {
await db.schema
.alterTable("softwares")
.alterColumn("versionMin", ac => ac.setNotNull())
.execute();

await db.schema
.alterTable("software_external_datas")
.dropColumn("softwareVersion")
.dropColumn("publicationTime")
.dropColumn("keywords")
.dropColumn("programmingLanguage")
.dropColumn("applicationCategory")
.execute();
}
26 changes: 22 additions & 4 deletions api/src/core/adapters/dbApi/kysely/pgDbApi.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ const softwareExternalData: SoftwareExternalData = {
websiteUrl: "https://example.com",
sourceUrl: "https://example.com/source",
documentationUrl: "https://example.com/documentation",
license: "MIT"
license: "MIT",
softwareVersion: "1.0.0",
keywords: ["Usefull", "Daily"],
programmingLanguage: ["C++"],
applicationCategory: ["Software Cat I", "Software Cat II"],
publicationTime: new Date(1561566581000)
};

const similarSoftwareExternalData: SoftwareExternalData = {
Expand All @@ -64,7 +69,12 @@ const similarSoftwareExternalData: SoftwareExternalData = {
websiteUrl: "https://example.similar.com",
sourceUrl: "https://example.similar.com/source",
documentationUrl: "https://example.similar.com/documentation",
license: "MIT"
license: "MIT",
softwareVersion: "3.0.2",
keywords: ["Infra", "Adminsys"],
programmingLanguage: ["Python3"],
applicationCategory: ["Software Cat I", "Software Cat II"],
publicationTime: new Date(1561566581000)
};

const parentSoftwareExternalData: SoftwareExternalData = {
Expand Down Expand Up @@ -151,6 +161,7 @@ describe("pgDbApi", () => {
addedTime: expect.any(Number),
updateTime: expect.any(Number),
annuaireCnllServiceProviders: undefined,
applicationCategory: ["Software Cat I", "Software Cat II"],
authors: softwareExternalData.developers.map(dev => ({
authorName: dev.name,
authorUrl: `https://www.wikidata.org/wiki/${dev.id}`
Expand All @@ -164,7 +175,10 @@ describe("pgDbApi", () => {
externalDataOrigin: "wikidata",
externalId,
keywords: ["bob", "l'éponge"],
latestVersion: undefined,
latestVersion: {
"publicationTime": 1561507200000,
"semVer": "1.0.0"
},
license: "MIT",
logoUrl: "https://example.com/logo.png",
officialWebsiteUrl: softwareExternalData.websiteUrl,
Expand All @@ -178,6 +192,7 @@ describe("pgDbApi", () => {
isFromFrenchPublicServices: false,
isPresentInSupportContract: true
},
programmingLanguage: ["C++"],
serviceProviders: [],
similarSoftwares: [
{
Expand Down Expand Up @@ -418,7 +433,10 @@ describe("pgDbApi", () => {
...softExtData,
developers: JSON.stringify(softExtData.developers),
label: JSON.stringify(softExtData.label),
description: JSON.stringify(softExtData.description)
description: JSON.stringify(softExtData.description),
keywords: JSON.stringify(softwareExternalData.keywords),
applicationCategory: JSON.stringify(softwareExternalData.applicationCategory),
programmingLanguage: JSON.stringify(softwareExternalData.programmingLanguage)
}))
)
.execute();
Expand Down
21 changes: 18 additions & 3 deletions api/src/core/adapters/fetchExternalData.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,20 +175,26 @@ describe("fetches software extra data (from different providers)", () => {
const updatedSoftwareExternalDatas = await db.selectFrom("software_external_datas").selectAll().execute();
expectToEqual(updatedSoftwareExternalDatas, [
{
applicationCategory: null,
description: "A framwork for creating react SPA that uses webpack as bundler",
developers: [],
documentationUrl: null,
externalDataOrigin: "wikidata",
externalId: craSoftwareFormData.externalId,
framaLibreId: null,
isLibreSoftware: true,
keywords: [],
label: "create-react-app",
license: "MIT licence",
logoUrl: null,
sourceUrl: "https://github.com/facebook/create-react-app",
websiteUrl: "https://create-react-app.dev/"
websiteUrl: "https://create-react-app.dev/",
programmingLanguage: [],
softwareVersion: "5.0.1",
publicationTime: new Date("2022-04-11T22:00:00.000Z")
},
{
applicationCategory: null,
description: "open-source JavaScript module bundler",
developers: [
{
Expand All @@ -201,12 +207,16 @@ describe("fetches software extra data (from different providers)", () => {
externalId: "Q111590996",
framaLibreId: null,
isLibreSoftware: true,
keywords: [],
label: "Vite",
license: "MIT licence",
logoUrl:
"//upload.wikimedia.org/wikipedia/commons/thumb/f/f1/Vitejs-logo.svg/220px-Vitejs-logo.svg.png",
sourceUrl: "https://github.com/vitejs/vite",
websiteUrl: "https://vitejs.dev/"
websiteUrl: "https://vitejs.dev/",
programmingLanguage: ["JavaScript"],
softwareVersion: "5.4.10",
publicationTime: new Date("2024-10-22T22:00:00.000Z")
}
]);

Expand Down Expand Up @@ -234,6 +244,7 @@ describe("fetches software extra data (from different providers)", () => {
const updatedSoftwareExternalDatas = await db.selectFrom("software_external_datas").selectAll().execute();
expectToEqual(updatedSoftwareExternalDatas, [
{
applicationCategory: null,
description: {
en: "open-source web server software",
fr: "serveur web sous licence libre"
Expand All @@ -249,12 +260,16 @@ describe("fetches software extra data (from different providers)", () => {
externalId: "Q11354",
framaLibreId: null,
isLibreSoftware: false,
keywords: [],
label: "Apache HTTP Server",
license: "Apache License v2.0",
logoUrl:
"//upload.wikimedia.org/wikipedia/commons/thumb/1/10/Apache_HTTP_server_logo_%282019-present%29.svg/220px-Apache_HTTP_server_logo_%282019-present%29.svg.png",
sourceUrl: "https://github.com/apache/httpd",
websiteUrl: "https://httpd.apache.org/"
websiteUrl: "https://httpd.apache.org/",
programmingLanguage: ["C"],
softwareVersion: "2.5.0-alpha",
publicationTime: new Date("2017-11-07T23:00:00.000Z")
}
]);

Expand Down
19 changes: 12 additions & 7 deletions api/src/core/adapters/hal/getHalSoftware.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,31 @@ describe("HAL", () => {
const result = await getHalSoftware("1715545");

expectToEqual(result, {
"description": { "en": "-" },
"description": { "en": "-", "fr": undefined },
"developers": [
{
"id": "gruenpeter,-morane",
"name": "Gruenpeter, Morane"
"id": "morane-gruenpeter",
"name": "Morane Gruenpeter"
}
],
"documentationUrl": "https://inria.hal.science/hal-01715545v1",
"documentationUrl": undefined,
"externalId": "1715545",
"framaLibreId": "",
"framaLibreId": undefined,
"isLibreSoftware": true,
"label": {
"en": "Battleship exercise",
"fr": "Battleship exercise"
},
"license": "MIT License",
"logoUrl": "",
"logoUrl": undefined,
"externalDataOrigin": "HAL",
"sourceUrl": "https://github.com/moranegg/Battleship",
"websiteUrl": "https://inria.hal.science/hal-01715545"
"websiteUrl": "https://inria.hal.science/hal-01715545v1",
"softwareVersion": undefined,
"keywords": undefined,
"programmingLanguage": undefined,
"applicationCategory": ["info"],
"publicationTime": new Date(1561566581000)
});
});
});
Expand Down
25 changes: 23 additions & 2 deletions api/src/core/adapters/hal/getHalSoftware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ export async function fetchHalSoftwareById(halDocid: string): Promise<HalRawSoft
`https://api.archives-ouvertes.fr/search/?q=docid:${halDocid}&wt=json&fl=${halSoftwareFieldsToReturnAsString}&sort=docid%20asc`
).catch(() => undefined);

console.log("Hal response status : ", res?.status);

if (res === undefined) {
throw new HalFetchError(undefined);
}
Expand All @@ -59,3 +57,26 @@ export async function fetchHalSoftwareById(halDocid: string): Promise<HalRawSoft

return json.response.docs[0];
}

export async function fetchHalSoftwares(): Promise<Array<HalRawSoftware>> {
// Filter only software who have an swhidId to filter clean data on https://hal.science, TODO remove and set it as an option to be generic
const url = `https://api.archives-ouvertes.fr/search/?q=docType_s:SOFTWARE&rows=10000&fl=${halSoftwareFieldsToReturnAsString}&fq=swhidId_s:["" TO *]`;

const res = await fetch(url).catch(err => {
console.error(err);
throw new HalFetchError(undefined);
});

if (res.status === 429) {
await new Promise(resolve => setTimeout(resolve, 100));
return fetchHalSoftwares();
}

if (res.status === 404) {
throw new HalFetchError(res.status);
}

const json = await res.json();

return json.response.docs;
}
Loading