Skip to content

Commit

Permalink
#303 : move framaLibreId to identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
guillermau committed Feb 26, 2025
1 parent 251105f commit 54c2464
Show file tree
Hide file tree
Showing 13 changed files with 72 additions and 19 deletions.
1 change: 0 additions & 1 deletion api/scripts/load-git-repo-in-pg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ const insertCompiledSoftwaresAndSoftwareExternalData = async (
description: JSON.stringify(softwareExternalData?.description ?? {}),
isLibreSoftware: softwareExternalData?.isLibreSoftware ?? false,
logoUrl: softwareExternalData?.logoUrl ?? null,
framaLibreId: softwareExternalData?.framaLibreId ?? null,
websiteUrl: softwareExternalData?.websiteUrl ?? null,
sourceUrl: softwareExternalData?.sourceUrl ?? null,
documentationUrl: softwareExternalData?.documentationUrl ?? null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ export const createGetCompiledData = (db: Kysely<Database>) => async (): Promise
description: ref("ext.description"),
isLibreSoftware: ref("ext.isLibreSoftware"),
logoUrl: ref("ext.logoUrl"),
framaLibreId: ref("ext.framaLibreId"),
websiteUrl: ref("ext.websiteUrl"),
sourceUrl: ref("ext.sourceUrl"),
documentationUrl: ref("ext.documentationUrl"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,6 @@ const makeGetSoftwareBuilder = (db: Kysely<Database>) =>
description: ref("ext.description"),
isLibreSoftware: ref("ext.isLibreSoftware"),
logoUrl: ref("ext.logoUrl"),
framaLibreId: ref("ext.framaLibreId"),
websiteUrl: ref("ext.websiteUrl"),
sourceUrl: ref("ext.sourceUrl"),
documentationUrl: ref("ext.documentationUrl"),
Expand Down
1 change: 0 additions & 1 deletion api/src/core/adapters/dbApi/kysely/kysely.database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ type SoftwareExternalDatasTable = {
description: string | JSONColumnType<LocalizedString>;
isLibreSoftware: boolean;
logoUrl: string | null;
framaLibreId: string | null;
websiteUrl: string | null;
sourceUrl: string | null;
documentationUrl: string | null;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Kysely } from "kysely";

export async function up(db: Kysely<any>): Promise<void> {
// Merging data
// The data on software_external_datas will update themselves on the next update
/* await db.updateTable('software_external_datas')
.set({
identifiers: sql`
COALESCE(
"identifiers",
'[]'::jsonb
) || jsonb_build_object(
'url', "framaLibreId",
'@type', 'PropertyValue',
'value', "framaLibreId",
'subjectOf', jsonb_build_object(
'url', 'https://framalibre.org',
'name', 'FramaLibre Official instance',
'@type', 'Website',
'additionalType', 'FramaLibre'
)
)::jsonb
`,
})
.execute(); */

await db.schema.alterTable("software_external_datas").dropColumn("framaLibreId").execute();
}

export async function down(db: Kysely<any>): Promise<void> {
await db.schema.alterTable("software_external_datas").addColumn("softwareId", "text").execute();

// The data on software_external_datas will update themselves on the next update
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ const softwareExternalData: SoftwareExternalData = {
description: { en: "Some software description" },
isLibreSoftware: true,
logoUrl: "https://example.com/logo.png",
framaLibreId: "",
websiteUrl: "https://example.com",
sourceUrl: "https://example.com/source",
documentationUrl: "https://example.com/documentation",
Expand Down Expand Up @@ -74,7 +73,6 @@ const similarSoftwareExternalData: SoftwareExternalData = {
description: { en: "Some similar software description" },
isLibreSoftware: true,
logoUrl: "https://example.com/similar-logo.png",
framaLibreId: "",
websiteUrl: "https://example.similar.com",
sourceUrl: "https://example.similar.com/source",
documentationUrl: "https://example.similar.com/documentation",
Expand Down
9 changes: 3 additions & 6 deletions api/src/core/adapters/fetchExternalData.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ describe("fetches software extra data (from different providers)", () => {
documentationUrl: null,
externalDataOrigin: "wikidata",
externalId: craSoftwareFormData.externalId,
framaLibreId: null,
isLibreSoftware: true,
keywords: [],
label: "create-react-app",
Expand All @@ -193,7 +192,7 @@ describe("fetches software extra data (from different providers)", () => {
websiteUrl: "https://create-react-app.dev/",
programmingLanguages: [],
referencePublications: null,
identifiers: null,
identifiers: [],
softwareVersion: "5.0.1",
publicationTime: new Date("2022-04-12T00:00:00.000Z")
},
Expand All @@ -211,7 +210,6 @@ describe("fetches software extra data (from different providers)", () => {
documentationUrl: "https://vitejs.dev/guide/",
externalDataOrigin: "wikidata",
externalId: "Q111590996",
framaLibreId: null,
isLibreSoftware: true,

keywords: [],
Expand All @@ -223,7 +221,7 @@ describe("fetches software extra data (from different providers)", () => {
websiteUrl: "https://vitejs.dev/",
programmingLanguages: ["JavaScript"],
referencePublications: null,
identifiers: null,
identifiers: [],
softwareVersion: expect.any(String),
publicationTime: expect.any(Date)
}
Expand Down Expand Up @@ -269,7 +267,6 @@ describe("fetches software extra data (from different providers)", () => {
documentationUrl: null,
externalDataOrigin: "wikidata",
externalId: "Q11354",
framaLibreId: null,
isLibreSoftware: false,
keywords: [],
label: "Apache HTTP Server",
Expand All @@ -279,7 +276,7 @@ describe("fetches software extra data (from different providers)", () => {
sourceUrl: "https://github.com/apache/httpd",
websiteUrl: "https://httpd.apache.org/",
referencePublications: null,
identifiers: null,
identifiers: [],
programmingLanguages: ["C"],
softwareVersion: "2.5.0-alpha",
publicationTime: new Date("2017-11-08T00:00:00.000Z")
Expand Down
1 change: 0 additions & 1 deletion api/src/core/adapters/hal/getHalSoftware.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ describe("HAL", () => {
],
"documentationUrl": undefined,
"externalId": "1715545",
"framaLibreId": undefined,
"isLibreSoftware": true,
"label": {
"en": "Battleship exercise",
Expand Down
1 change: 0 additions & 1 deletion api/src/core/adapters/hal/getHalSoftwareExternalData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ export const getHalSoftwareExternalData: GetSoftwareExternalData = memoize(
isLibreSoftware: halRawSoftware.openAccess_bool,
// Optionnal
logoUrl: undefined,
framaLibreId: undefined,
websiteUrl: halRawSoftware.uri_s,
sourceUrl: halRawSoftware?.softCodeRepository_s?.[0],
documentationUrl: undefined, // TODO no info about documentation in HAL check on SWH or Repo ?
Expand Down
19 changes: 17 additions & 2 deletions api/src/core/adapters/wikidata/getWikidataSoftware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,22 @@ export const getWikidataSoftware: GetSoftwareExternalData = memoize(
? wikidataTimeToJSDate(publicationTimeDateValue)
: undefined;

const framaLibreId = getClaimDataValue<"string">("P4107")[0];

const makeFramaIndentifer = (framaLibreId: string): SILL.Identification => {
return {
url: new URL(framaLibreId),
"@type": "PropertyValue",
value: framaLibreId,
subjectOf: {
url: new URL("https://framalibre.org"),
name: "FramaLibre Official instance",
"@type": "Website",
additionalType: "FramaLibre"
}
};
};

return {
externalId: wikidataId,
externalDataOrigin: "wikidata",
Expand Down Expand Up @@ -178,7 +194,6 @@ export const getWikidataSoftware: GetSoftwareExternalData = memoize(

return url;
})(),
"framaLibreId": getClaimDataValue<"string">("P4107")[0],
...(() => {
const websiteUrl = getClaimDataValue<"string">("P856")[0];
const sourceUrl = getClaimDataValue<"string">("P1324")[0];
Expand Down Expand Up @@ -257,7 +272,7 @@ export const getWikidataSoftware: GetSoftwareExternalData = memoize(
applicationCategories: undefined, // doesn't exit on wiki data
referencePublications: undefined, // doesn't exit on wiki data
publicationTime: publicationTimeDate,
identifiers: undefined
identifiers: framaLibreId?.includes("https") ? [makeFramaIndentifer(framaLibreId)] : []
};
},
{
Expand Down
1 change: 0 additions & 1 deletion api/src/core/ports/GetSoftwareExternalData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export type SoftwareExternalData = {
isLibreSoftware: boolean;
} & PartialNoOptional<{
logoUrl: string;
framaLibreId: string;
websiteUrl: string;
sourceUrl: string;
documentationUrl: string;
Expand Down
11 changes: 10 additions & 1 deletion api/src/types/SILL.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
export namespace SILL {
export type Sources = "GitLab" | "HAL" | "WikiData" | "SWH" | "Orcid" | "doi" | "GitHub" | "ComptoirDuLibre";
export type Sources =
| "GitLab"
| "HAL"
| "WikiData"
| "SWH"
| "Orcid"
| "doi"
| "GitHub"
| "ComptoirDuLibre"
| "FramaLibre";

// from https://schema.org/PropertyValue
export type Identification = {
Expand Down
9 changes: 8 additions & 1 deletion web/src/ui/shared/LogoURLButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,14 @@ const resolveLogoFromType = (
URLlogo: new URL(
"https://comptoir-du-libre.org/img/favicon/CDL-Favicon.16_16.png?v2.13.2_DEV"
),
textFromURL: "GitComptoir Du Libre"
textFromURL: "Comptoir Du Libre"
};
case "FramaLibre":
return {
URLlogo: new URL(
"https://framasoft.org/nav/img/icons/favicon/sites/libre.png"
),
textFromURL: "FramaLibre"
};
default:
sourceType satisfies never;
Expand Down

0 comments on commit 54c2464

Please sign in to comment.