diff --git a/api/src/core/adapters/dbApi/kysely/createPgSoftwareRepository.ts b/api/src/core/adapters/dbApi/kysely/createPgSoftwareRepository.ts index d0f998ea..34ca16fe 100644 --- a/api/src/core/adapters/dbApi/kysely/createPgSoftwareRepository.ts +++ b/api/src/core/adapters/dbApi/kysely/createPgSoftwareRepository.ts @@ -191,7 +191,9 @@ export const createPgSoftwareRepository = (db: Kysely): SoftwareReposi parentWikidataSoftware: parentExternalData, keywords: software?.keywords ?? softwareExternalData?.keywords ?? [], programmingLanguages: softwareExternalData?.programmingLanguages ?? [], - applicationCategories: softwareExternalData?.applicationCategories ?? [] + applicationCategories: software.categories.concat( + softwareExternalData?.applicationCategories ?? [] + ) }); }), getById: getBySoftwareId, @@ -285,7 +287,9 @@ export const createPgSoftwareRepository = (db: Kysely): SoftwareReposi software.comptoirDuLibreSoftware?.providers.length ?? 0, testUrl: testUrls[0]?.url, parentWikidataSoftware: parentExternalData ?? undefined, - applicationCategories: softwareExternalData?.applicationCategories ?? [], + applicationCategories: software.categories.concat( + softwareExternalData?.applicationCategories ?? [] + ), programmingLanguages: softwareExternalData?.programmingLanguages ?? [] }); } @@ -547,6 +551,6 @@ const makeGetSoftwareById = testUrl: testUrls[0]?.url, parentWikidataSoftware: parentExternalData, programmingLanguages: softwareExternalData?.programmingLanguages ?? [], - applicationCategories: softwareExternalData?.applicationCategories ?? [] + applicationCategories: software.categories.concat(softwareExternalData?.applicationCategories ?? []) }); }); diff --git a/web/src/core/adapter/sillApiMock.ts b/web/src/core/adapter/sillApiMock.ts index 3a4b3455..2f7e437a 100644 --- a/web/src/core/adapter/sillApiMock.ts +++ b/web/src/core/adapter/sillApiMock.ts @@ -98,7 +98,7 @@ export const sillApi: SillApi = { "testUrl": undefined, "addedTime": Date.now(), "updateTime": Date.now(), - "categories": [], + "applicationCategories": [], "prerogatives": { "doRespectRgaa": false, "isFromFrenchPublicServices": formData.isFromFrenchPublicService, @@ -111,8 +111,7 @@ export const sillApi: SillApi = { }, "keywords": [], "annuaireCnllServiceProviders": [], - "programmingLanguages": ["c++"], - "applicationCategories": [] + "programmingLanguages": ["c++"] }; softwares.push(software); @@ -154,7 +153,7 @@ export const sillApi: SillApi = { "testUrl": undefined, "addedTime": Date.now(), "updateTime": Date.now(), - "categories": [], + "applicationCategories": [], "prerogatives": { "doRespectRgaa": false, "isFromFrenchPublicServices": formData.isFromFrenchPublicService, @@ -168,7 +167,6 @@ export const sillApi: SillApi = { }, "keywords": [], "annuaireCnllServiceProviders": [], - "applicationCategories": [], "programmingLanguages": [] }) }; @@ -326,7 +324,7 @@ const softwares = [ "addedTime": 1670416144, "updateTime": 1674739365178, "dereferencing": undefined, - "categories": ["messaging"], + "applicationCategories": ["messaging"], "softwareType": { "type": "cloud" }, @@ -341,7 +339,6 @@ const softwares = [ "DINUM": { "referentCount": 2, "userCount": 43 } }, "keywords": [], - "applicationCategories": [], "programmingLanguages": [] }), id({ @@ -387,7 +384,7 @@ const softwares = [ "addedTime": 1674739365178, "updateTime": 1674739365178, "dereferencing": undefined, - "categories": ["traitement de texte"], + "applicationCategories": ["traitement de texte"], "prerogatives": { "doRespectRgaa": true, "isFromFrenchPublicServices": true, @@ -407,7 +404,6 @@ const softwares = [ "CA du Puy-en-Velay": { "referentCount": 1, "userCount": 0 } }, "keywords": [], - "applicationCategories": [], "programmingLanguages": [] }), id({ @@ -453,7 +449,7 @@ const softwares = [ "addedTime": 1674739365178, "updateTime": 1674739365178, "dereferencing": undefined, - "categories": ["cloud", "software"], + "applicationCategories": ["cloud", "software"], "prerogatives": { "doRespectRgaa": false, "isFromFrenchPublicServices": false, @@ -465,7 +461,6 @@ const softwares = [ "DINUM": { "referentCount": 2, "userCount": 43 } }, "keywords": [], - "applicationCategories": [], "programmingLanguages": [] }), id({ @@ -514,7 +509,7 @@ const softwares = [ "addedTime": 1674739365178, "updateTime": 1674739365178, "dereferencing": undefined, - "categories": ["player"], + "applicationCategories": ["player"], "prerogatives": { "doRespectRgaa": false, "isFromFrenchPublicServices": false, @@ -522,7 +517,6 @@ const softwares = [ }, "userAndReferentCountByOrganization": {}, "keywords": [], - "applicationCategories": [], "programmingLanguages": [] }), id({ @@ -570,7 +564,7 @@ const softwares = [ "addedTime": 1674739365178, "updateTime": 1674739365178, "dereferencing": undefined, - "categories": ["cloud"], + "applicationCategories": ["cloud"], "prerogatives": { "doRespectRgaa": false, "isFromFrenchPublicServices": false, @@ -582,7 +576,6 @@ const softwares = [ "DINUM": { "referentCount": 2, "userCount": 43 } }, "keywords": [], - "applicationCategories": [], "programmingLanguages": [] }), id({ @@ -645,7 +638,7 @@ const softwares = [ "addedTime": 1674739365178, "updateTime": 1674739365178, "dereferencing": undefined, - "categories": ["cloud"], + "applicationCategories": ["cloud"], "prerogatives": { "doRespectRgaa": false, "isFromFrenchPublicServices": false, @@ -657,7 +650,6 @@ const softwares = [ "DINUM": { "referentCount": 2, "userCount": 43 } }, "keywords": [], - "applicationCategories": [], "programmingLanguages": [] }), id({ @@ -702,7 +694,7 @@ const softwares = [ "addedTime": 1674739365178, "updateTime": 1674739365178, "dereferencing": undefined, - "categories": ["cloud"], + "applicationCategories": ["cloud"], "prerogatives": { "doRespectRgaa": false, "isFromFrenchPublicServices": false, @@ -713,7 +705,6 @@ const softwares = [ "DINUM": { "referentCount": 2, "userCount": 43 } }, "keywords": [], - "applicationCategories": [], "programmingLanguages": [] }), id({ @@ -763,7 +754,7 @@ const softwares = [ "addedTime": 1674739365178, "updateTime": 1674739365178, "dereferencing": undefined, - "categories": ["cloud"], + "applicationCategories": ["cloud"], "prerogatives": { "doRespectRgaa": false, "isFromFrenchPublicServices": false, @@ -784,7 +775,6 @@ const softwares = [ "DINUM": { "referentCount": 2, "userCount": 43 } }, "keywords": [], - "applicationCategories": [], "programmingLanguages": [] }), id({ @@ -823,7 +813,7 @@ const softwares = [ "addedTime": 1674739365178, "updateTime": 1674739365178, "dereferencing": undefined, - "categories": ["cloud"], + "applicationCategories": ["cloud"], "softwareType": { "type": "stack" }, @@ -836,7 +826,6 @@ const softwares = [ "CA du Puy-en-Velay": { "referentCount": 0, "userCount": 1 } }, "keywords": [], - "applicationCategories": [], "programmingLanguages": [] }), id({ @@ -875,7 +864,7 @@ const softwares = [ "addedTime": 1674739365178, "updateTime": 1674739365178, "dereferencing": undefined, - "categories": ["cloud"], + "applicationCategories": ["cloud"], "prerogatives": { "doRespectRgaa": false, "isFromFrenchPublicServices": false, @@ -887,7 +876,6 @@ const softwares = [ "DINUM": { "referentCount": 2, "userCount": 43 } }, "keywords": [], - "applicationCategories": [], "programmingLanguages": [] }), id({ @@ -927,7 +915,7 @@ const softwares = [ "addedTime": 1674739365178, "updateTime": 1674739365178, "dereferencing": undefined, - "categories": ["cloud"], + "applicationCategories": ["cloud"], "prerogatives": { "doRespectRgaa": false, "isFromFrenchPublicServices": false, @@ -935,7 +923,6 @@ const softwares = [ }, "userAndReferentCountByOrganization": {}, "keywords": [], - "applicationCategories": [], "programmingLanguages": [] }), id({ @@ -975,7 +962,7 @@ const softwares = [ "addedTime": 1674739365178, "updateTime": 1674739365178, "dereferencing": undefined, - "categories": ["cloud"], + "applicationCategories": ["cloud"], "prerogatives": { "doRespectRgaa": false, "isFromFrenchPublicServices": false, @@ -983,7 +970,6 @@ const softwares = [ }, "userAndReferentCountByOrganization": {}, "keywords": [], - "applicationCategories": [], "programmingLanguages": [] }), id({ @@ -1023,7 +1009,7 @@ const softwares = [ "addedTime": 1674739365178, "updateTime": 1674739365178, "dereferencing": undefined, - "categories": ["cloud"], + "applicationCategories": ["cloud"], "prerogatives": { "doRespectRgaa": false, "isFromFrenchPublicServices": false, @@ -1031,7 +1017,6 @@ const softwares = [ }, "userAndReferentCountByOrganization": {}, "keywords": [], - "applicationCategories": [], "programmingLanguages": [] }), id({ @@ -1071,7 +1056,7 @@ const softwares = [ "addedTime": 1674739365178, "updateTime": 1674739365178, "dereferencing": undefined, - "categories": ["cloud"], + "applicationCategories": ["cloud"], "prerogatives": { "doRespectRgaa": false, "isFromFrenchPublicServices": false, @@ -1079,7 +1064,6 @@ const softwares = [ }, "userAndReferentCountByOrganization": {}, "keywords": [], - "applicationCategories": [], "programmingLanguages": [] }), id({ @@ -1119,7 +1103,7 @@ const softwares = [ "addedTime": 1674739365178, "updateTime": 1674739365178, "dereferencing": undefined, - "categories": ["cloud"], + "applicationCategories": ["cloud"], "prerogatives": { "doRespectRgaa": false, "isFromFrenchPublicServices": false, @@ -1127,7 +1111,6 @@ const softwares = [ }, "userAndReferentCountByOrganization": {}, "keywords": [], - "applicationCategories": [], "programmingLanguages": [] }), id({ @@ -1167,7 +1150,7 @@ const softwares = [ "addedTime": 1674739365178, "updateTime": 1674739365178, "dereferencing": undefined, - "categories": ["cloud"], + "applicationCategories": ["cloud"], "prerogatives": { "doRespectRgaa": false, "isFromFrenchPublicServices": false, @@ -1175,7 +1158,6 @@ const softwares = [ }, "userAndReferentCountByOrganization": {}, "keywords": [], - "applicationCategories": [], "programmingLanguages": [] }), id({ @@ -1215,7 +1197,7 @@ const softwares = [ "addedTime": 1674739365178, "updateTime": 1674739365178, "dereferencing": undefined, - "categories": ["cloud"], + "applicationCategories": ["cloud"], "prerogatives": { "doRespectRgaa": false, "isFromFrenchPublicServices": false, @@ -1223,7 +1205,6 @@ const softwares = [ }, "userAndReferentCountByOrganization": {}, "keywords": [], - "applicationCategories": [], "programmingLanguages": [] }), id({ @@ -1263,7 +1244,7 @@ const softwares = [ "addedTime": 1674739365178, "updateTime": 1674739365178, "dereferencing": undefined, - "categories": ["cloud"], + "applicationCategories": ["cloud"], "prerogatives": { "doRespectRgaa": false, "isFromFrenchPublicServices": false, @@ -1271,7 +1252,6 @@ const softwares = [ }, "userAndReferentCountByOrganization": {}, "keywords": [], - "applicationCategories": [], "programmingLanguages": [] }) ]; diff --git a/web/src/core/usecases/softwareCatalog/selectors.ts b/web/src/core/usecases/softwareCatalog/selectors.ts index 8cbe7d5f..70edba50 100644 --- a/web/src/core/usecases/softwareCatalog/selectors.ts +++ b/web/src/core/usecases/softwareCatalog/selectors.ts @@ -286,7 +286,7 @@ const categoryOptions = createSelector( Array.from( new Set( internalSoftwares - .map(({ categories }) => categories) + .map(({ applicationCategories }) => applicationCategories) .reduce((prev, curr) => [...prev, ...curr], []) ) ).map(category => [category, 0]) @@ -322,8 +322,8 @@ const categoryOptions = createSelector( }); } - tmpSoftwares.forEach(({ categories }) => - categories.forEach( + tmpSoftwares.forEach(({ applicationCategories }) => + applicationCategories.forEach( category => softwareCountInCurrentFilterByCategory[category]++ ) ); @@ -635,7 +635,9 @@ function filterByCategory(params: { }) { const { softwares, category } = params; - return softwares.filter(({ categories }) => categories.includes(category)); + return softwares.filter(({ applicationCategories }) => + applicationCategories.includes(category) + ); } function filterByEnvironnement(params: { @@ -717,14 +719,13 @@ function apiSoftwareToInternalSoftware(params: { testUrl, addedTime, updateTime, - categories, + applicationCategories, prerogatives, softwareType, userAndReferentCountByOrganization, similarSoftwares, keywords, - programmingLanguages, - applicationCategories + programmingLanguages } = apiSoftware; assert< @@ -780,7 +781,7 @@ function apiSoftwareToInternalSoftware(params: { testUrl, addedTime, updateTime, - categories, + applicationCategories, "organizations": objectKeys(userAndReferentCountByOrganization), parentSoftware, softwareType, @@ -812,8 +813,7 @@ function apiSoftwareToInternalSoftware(params: { return search; })(), userDeclaration, - programmingLanguages, - applicationCategories + programmingLanguages }; } @@ -833,7 +833,7 @@ function internalSoftwareToExternalSoftware(params: { testUrl, addedTime, updateTime, - categories, + applicationCategories, organizations, prerogatives: { isFromFrenchPublicServices, @@ -845,7 +845,6 @@ function internalSoftwareToExternalSoftware(params: { softwareType, userDeclaration, programmingLanguages, - applicationCategories, ...rest } = internalSoftware; diff --git a/web/src/core/usecases/softwareCatalog/state.ts b/web/src/core/usecases/softwareCatalog/state.ts index 39be5de0..12d0f6c8 100644 --- a/web/src/core/usecases/softwareCatalog/state.ts +++ b/web/src/core/usecases/softwareCatalog/state.ts @@ -103,7 +103,6 @@ export namespace State { export type Internal = Common & { addedTime: number; updateTime: number; - categories: string[]; organizations: string[]; prerogatives: OmitFromExisting< Prerogatives, diff --git a/web/src/core/usecases/softwareCatalog/thunks.ts b/web/src/core/usecases/softwareCatalog/thunks.ts index d1dd2df8..a9ff76c9 100644 --- a/web/src/core/usecases/softwareCatalog/thunks.ts +++ b/web/src/core/usecases/softwareCatalog/thunks.ts @@ -221,14 +221,13 @@ function apiSoftwareToInternalSoftware(params: { testUrl, addedTime, updateTime, - categories, + applicationCategories, prerogatives, softwareType, userAndReferentCountByOrganization, similarSoftwares, keywords, - programmingLanguages, - applicationCategories + programmingLanguages } = apiSoftware; assert< @@ -302,7 +301,7 @@ function apiSoftwareToInternalSoftware(params: { testUrl, addedTime, updateTime, - categories, + applicationCategories, "organizations": objectKeys(userAndReferentCountByOrganization), parentSoftware, softwareType, @@ -334,8 +333,7 @@ function apiSoftwareToInternalSoftware(params: { return search; })(), userDeclaration, - programmingLanguages, - applicationCategories + programmingLanguages }; }