Skip to content

Commit

Permalink
remove otherWikidataSoftware from model
Browse files Browse the repository at this point in the history
  • Loading branch information
JeromeBu committed Jul 26, 2024
1 parent 24af556 commit 6052494
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 71 deletions.
45 changes: 1 addition & 44 deletions api/src/core/adapters/compileData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,41 +192,7 @@ export function createCompileData(params: {
};
})
).then(similarWikidataSoftwares => similarWikidataSoftwares.filter(exclude(undefined))),
Promise.all(
instanceRows
.filter(({ mainSoftwareSillId }) => mainSoftwareSillId === sillId)
.map(async ({ id, otherSoftwareWikidataIds }) => {
const instance_cache = cache?.instances.find(instance => instance.id === id);

return {
"id": id,
"otherWikidataSoftwares": await Promise.all(
otherSoftwareWikidataIds.map(async wikidataId => {
const otherWikidataSoftware_cache =
instance_cache?.otherWikidataSoftwares.find(
wikidataSoftware => wikidataSoftware.externalId === wikidataId
);

if (otherWikidataSoftware_cache !== undefined) {
return otherWikidataSoftware_cache;
}

const wikidataSoftware = await getExternalSoftware(wikidataId);

if (wikidataSoftware === undefined) {
return undefined;
}

return {
"externalId": wikidataSoftware.externalId,
"label": wikidataSoftware.label,
"description": wikidataSoftware.description
};
})
).then(otherWikidataSoftwares => otherWikidataSoftwares.filter(exclude(undefined)))
};
})
)
instanceRows.filter(({ mainSoftwareSillId }) => mainSoftwareSillId === sillId)
] as const);

partialSoftwareBySillId[sillId] = {
Expand Down Expand Up @@ -380,15 +346,6 @@ export function createCompileData(params: {
organization,
targetAudience,
publicUrl,
"otherWikidataSoftwares": (() => {
const instance = partialSoftwareBySillId[sillId].instances.find(
({ id }) => id === instanceId
);

assert(instance !== undefined);

return instance.otherWikidataSoftwares;
})(),
addedByAgentEmail
}))
})
Expand Down
3 changes: 1 addition & 2 deletions api/src/core/ports/CompileData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export namespace CompileData {
keywords: string[] | undefined;
}
| undefined;
instances: Pick<CompiledData.Instance, "id" | "otherWikidataSoftwares">[];
instances: Pick<CompiledData.Instance, "id">[];
};
}

Expand Down Expand Up @@ -100,7 +100,6 @@ export namespace CompiledData {
organization: string;
targetAudience: string;
publicUrl: string | undefined;
otherWikidataSoftwares: Pick<SoftwareExternalData, "externalId" | "label" | "description">[];
};
}

Expand Down
1 change: 0 additions & 1 deletion api/src/core/ports/DbApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ export namespace Db {
organization: string;
targetAudience: string;
publicUrl: string | undefined;
otherSoftwareWikidataIds: string[];
addedByAgentEmail: string;
referencedSinceTime: number;
updateTime: number;
Expand Down
27 changes: 8 additions & 19 deletions api/src/core/usecases/readWriteSillData/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,25 +225,14 @@ const instances = createSelector(compiledData, (compiledData): Instance[] =>
compiledData
.map(software => software.instances.map(instance => ({ ...instance, "mainSoftwareSillId": software.id })))
.flat()
.map(
({
id,
organization,
targetAudience,
publicUrl,
otherWikidataSoftwares,
addedByAgentEmail,
mainSoftwareSillId
}) => ({
id,
mainSoftwareSillId,
organization,
targetAudience,
publicUrl,
otherWikidataSoftwares,
addedByAgentEmail
})
)
.map(({ id, organization, targetAudience, publicUrl, addedByAgentEmail, mainSoftwareSillId }) => ({
id,
mainSoftwareSillId,
organization,
targetAudience,
publicUrl,
addedByAgentEmail
}))
);

const agents = createSelector(sliceState, state =>
Expand Down
2 changes: 0 additions & 2 deletions api/src/core/usecases/readWriteSillData/thunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,6 @@ export const thunks = {
"addedByAgentEmail": agent.email,
"organization": formData.organization,
"mainSoftwareSillId": formData.mainSoftwareSillId,
"otherSoftwareWikidataIds": formData.otherSoftwareWikidataIds,
"publicUrl": formData.publicUrl,
"targetAudience": formData.targetAudience,
"referencedSinceTime": now,
Expand Down Expand Up @@ -513,7 +512,6 @@ export const thunks = {
addedByAgentEmail,
mainSoftwareSillId,
organization,
otherSoftwareWikidataIds,
publicUrl,
targetAudience,
referencedSinceTime,
Expand Down
1 change: 0 additions & 1 deletion api/src/core/usecases/readWriteSillData/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ export type Instance = {
organization: string;
targetAudience: string;
publicUrl: string | undefined;
otherWikidataSoftwares: Pick<SoftwareExternalData, "externalId" | "label" | "description">[];
};

export type SoftwareType = SoftwareType.Desktop | SoftwareType.CloudNative | SoftwareType.Stack;
Expand Down
2 changes: 0 additions & 2 deletions api/src/rpc/routes.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ describe("RPC e2e tests", () => {
"addedByAgentEmail": defaultUser.email,
"mainSoftwareSillId": expectedSoftwareId,
"organization": instanceFormData.organization,
"otherSoftwareWikidataIds": instanceFormData.otherSoftwareWikidataIds,
"publicUrl": instanceFormData.publicUrl,
"targetAudience": instanceFormData.targetAudience
});
Expand All @@ -172,7 +171,6 @@ describe("RPC e2e tests", () => {
"id": 1,
"mainSoftwareSillId": expectedSoftwareId,
"organization": instanceFormData.organization,
"otherWikidataSoftwares": [],
"publicUrl": instanceFormData.publicUrl,
"targetAudience": instanceFormData.targetAudience
});
Expand Down

0 comments on commit 6052494

Please sign in to comment.