Skip to content

Commit

Permalink
#129 : fix api test
Browse files Browse the repository at this point in the history
  • Loading branch information
guillermau committed Jan 14, 2025
1 parent a8e7a2b commit 5e695b5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
15 changes: 13 additions & 2 deletions api/src/core/adapters/dbApi/kysely/createPgSoftwareRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ export const createPgSoftwareRepository = (db: Kysely<Database>): SoftwareReposi
programmingLanguages: softwareExternalData?.programmingLanguages ?? [],
applicationCategories: software.categories.concat(
softwareExternalData?.applicationCategories ?? []
)
),
categories: undefined // merged in applicationCategories, set to undefined to remove it
});
}),
getById: getBySoftwareId,
Expand Down Expand Up @@ -290,6 +291,7 @@ export const createPgSoftwareRepository = (db: Kysely<Database>): SoftwareReposi
applicationCategories: software.categories.concat(
softwareExternalData?.applicationCategories ?? []
),
categories: undefined, // merged in applicationCategories, set to undefined to remove it
programmingLanguages: softwareExternalData?.programmingLanguages ?? []
});
}
Expand Down Expand Up @@ -511,6 +513,12 @@ const getUserAndReferentCountByOrganizationBySoftwareId = async (
);
};

const filterDuplicate = (array: any[]) => {
return array.filter(function (item: any, pos: number) {
return array.indexOf(item) == pos;
});
};

const makeGetSoftwareById =
(db: Kysely<Database>) =>
async (softwareId: number): Promise<Software | undefined> =>
Expand Down Expand Up @@ -551,6 +559,9 @@ const makeGetSoftwareById =
testUrl: testUrls[0]?.url,
parentWikidataSoftware: parentExternalData,
programmingLanguages: softwareExternalData?.programmingLanguages ?? [],
applicationCategories: software.categories.concat(softwareExternalData?.applicationCategories ?? [])
applicationCategories: filterDuplicate(
software.categories.concat(softwareExternalData?.applicationCategories ?? [])
),
categories: undefined // merged in applicationCategories, set to undefined to remove it
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ describe("pgDbApi", () => {
authorName: dev.name,
authorUrl: `https://www.wikidata.org/wiki/${dev.id}`
})),
categories: [],
codeRepositoryUrl: softwareExternalData.sourceUrl,
comptoirDuLibreId: 50,
comptoirDuLibreServiceProviderCount: 0,
Expand Down
3 changes: 1 addition & 2 deletions api/src/core/usecases/readWriteSillData/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export type Software = {
lastRecommendedVersion?: string;
}
| undefined;
categories: string[];
applicationCategories: string[];
prerogatives: Prerogatives;
userAndReferentCountByOrganization: Record<string, { userCount: number; referentCount: number }>;
authors: {
Expand Down Expand Up @@ -62,7 +62,6 @@ export type Software = {
similarSoftwares: Software.SimilarSoftware[];
keywords: string[];
programmingLanguages: string[];
applicationCategories: string[];
};

export namespace Software {
Expand Down

0 comments on commit 5e695b5

Please sign in to comment.