Skip to content

Commit 51e1333

Browse files
committed
feat(api): add new field providers on softwareExternalData
refs: #296
1 parent 61bc6ae commit 51e1333

File tree

9 files changed

+35
-12
lines changed

9 files changed

+35
-12
lines changed

api/src/core/adapters/dbApi/kysely/createPgSoftwareExternalDataRepository.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ export const createPgSoftwareExternalDataRepository = (db: Kysely<Database>): So
4949
programmingLanguages: JSON.stringify(softwareExternalData.programmingLanguages),
5050
referencePublications: JSON.stringify(softwareExternalData.referencePublications),
5151
identifiers: JSON.stringify(softwareExternalData.identifiers),
52-
description: JSON.stringify(softwareExternalData.description)
52+
description: JSON.stringify(softwareExternalData.description),
53+
providers: JSON.stringify(softwareExternalData.providers)
5354
})
5455
.executeTakeFirst();
5556
},
@@ -64,7 +65,8 @@ export const createPgSoftwareExternalDataRepository = (db: Kysely<Database>): So
6465
programmingLanguages: JSON.stringify(softwareExternalData.programmingLanguages),
6566
referencePublications: JSON.stringify(softwareExternalData.referencePublications),
6667
identifiers: JSON.stringify(softwareExternalData.identifiers),
67-
description: JSON.stringify(softwareExternalData.description)
68+
description: JSON.stringify(softwareExternalData.description),
69+
providers: JSON.stringify(softwareExternalData.providers)
6870
};
6971

7072
await db

api/src/core/adapters/dbApi/kysely/kysely.database.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ export type SoftwareExternalDatasTable = {
152152
publicationTime: Date | null;
153153
identifiers: JSONColumnType<SchemaIdentifier[]> | null;
154154
lastDataFetchAt: number | null;
155+
providers: JSONColumnType<Array<SchemaOrganization>> | null;
155156
};
156157

157158
type SoftwareType =
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import type { Kysely } from "kysely";
2+
3+
export async function up(db: Kysely<any>): Promise<void> {
4+
await db.schema.alterTable("software_external_datas").addColumn("providers", "jsonb").execute();
5+
}
6+
7+
export async function down(db: Kysely<any>): Promise<void> {
8+
await db.schema.alterTable("software_external_datas").dropColumn("providers").execute();
9+
}

api/src/core/adapters/dbApi/kysely/pgDbApi.integration.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ const softwareExternalData: SoftwareExternalData = {
7070
applicationCategories: ["Software Cat I", "Software Cat II"],
7171
referencePublications: undefined,
7272
identifiers: undefined,
73-
publicationTime: new Date(1561566581000)
73+
publicationTime: new Date(1561566581000),
74+
providers: []
7475
};
7576

7677
const similarSoftwareExternalData: SoftwareExternalData = {
@@ -103,7 +104,8 @@ const similarSoftwareExternalData: SoftwareExternalData = {
103104
applicationCategories: ["Software Cat I", "Software Cat II"],
104105
referencePublications: undefined,
105106
identifiers: undefined,
106-
publicationTime: new Date(1561566581000)
107+
publicationTime: new Date(1561566581000),
108+
providers: []
107109
};
108110

109111
const insertedAgent = {
@@ -445,7 +447,8 @@ describe("pgDbApi", () => {
445447
applicationCategories: JSON.stringify(softExtData.applicationCategories),
446448
programmingLanguages: JSON.stringify(softExtData.programmingLanguages),
447449
identifiers: JSON.stringify(softExtData.identifiers),
448-
referencePublications: JSON.stringify(softExtData.referencePublications)
450+
referencePublications: JSON.stringify(softExtData.referencePublications),
451+
providers: JSON.stringify(softExtData.providers)
449452
}))
450453
)
451454
.execute();

api/src/core/adapters/hal/getHalSoftware.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ describe("HAL", () => {
8080
"swh:1:dir:424f2533fe51aa8a49d891f8413dd089995cc851;origin=https://hal.archives-ouvertes.fr/hal-01715545;visit=swh:1:snp:9f3237e88d818d975a63da2d5e04d9ad38b42581;anchor=swh:1:rev:8b71800feca2e28cc0f7f78d248e49244b554875;path=/"
8181
}
8282
],
83-
"publicationTime": new Date(1521545908000)
83+
"publicationTime": new Date(1521545908000),
84+
"providers": []
8485
});
8586
});
8687
});

api/src/core/adapters/hal/getHalSoftwareExternalData.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,8 @@ export const getHalSoftwareExternalData: GetSoftwareExternalData = memoize(
229229
halRawSoftware.relatedPublication_s.map(id => buildReferencePublication(parseScolarId(id), id))
230230
)
231231
).filter(val => val !== undefined),
232-
identifiers: identifiers
232+
identifiers: identifiers,
233+
providers: []
233234
};
234235
},
235236
{

api/src/core/ports/GetSoftwareExternalData.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export type SoftwareExternalData = {
3939
publicationTime: Date;
4040
referencePublications: ScholarlyArticle[];
4141
identifiers: SchemaIdentifier[];
42+
providers: Array<SchemaOrganization>;
4243
}>;
4344

4445
export type SimilarSoftwareExternalData = Pick<

api/src/core/usecases/refreshExternalData.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,8 @@ describe("fetches software extra data (from different providers)", () => {
254254
identifiers: [],
255255
softwareVersion: "5.0.1",
256256
publicationTime: new Date("2022-04-12T00:00:00.000Z"),
257-
lastDataFetchAt: expect.any(Number)
257+
lastDataFetchAt: expect.any(Number),
258+
providers: []
258259
},
259260
{
260261
applicationCategories: undefined,
@@ -289,7 +290,8 @@ describe("fetches software extra data (from different providers)", () => {
289290
identifiers: [],
290291
softwareVersion: expect.any(String),
291292
publicationTime: expect.any(Date),
292-
lastDataFetchAt: expect.any(Number)
293+
lastDataFetchAt: expect.any(Number),
294+
providers: []
293295
}
294296
]);
295297

@@ -373,7 +375,8 @@ describe("fetches software extra data (from different providers)", () => {
373375
programmingLanguages: ["C"],
374376
softwareVersion: "2.5.0-alpha",
375377
publicationTime: new Date("2017-11-08T00:00:00.000Z"),
376-
lastDataFetchAt: expect.any(Number)
378+
lastDataFetchAt: expect.any(Number),
379+
providers: []
377380
},
378381
emptyExternalDataCleaned({
379382
externalId: "Q118629387",

api/src/tools/test.helpers.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ export const emptyExternalData = (params: { softwareId?: number; externalId: str
9696
identifiers: null,
9797
sourceSlug,
9898
softwareId,
99-
lastDataFetchAt: null
99+
lastDataFetchAt: null,
100+
providers: []
100101
};
101102
};
102103

@@ -122,7 +123,8 @@ export const emptyExternalDataCleaned = (params: { softwareId?: number; external
122123
identifiers: undefined,
123124
sourceSlug,
124125
softwareId,
125-
lastDataFetchAt: undefined
126+
lastDataFetchAt: undefined,
127+
providers: []
126128
};
127129
};
128130

0 commit comments

Comments
 (0)