Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DIGG-508: Updating filter for high value dataset #553

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,20 @@ export function createSearchProviderSettings(env: EnvSettings, lang: string) {
group: "distribution",
},
{
resource: "http://data.europa.eu/r5r/applicableLegislation",
resource: "http://data.europa.eu/r5r/hvdCategory",
type: ESType.uri,
dcatProperty: "dcatap:applicableLegislation",
dcatType: "choice",
dcatProperty: "dcatap:hvdCategory",
dcatFilterEnabled: false,
indexOrder: 6,
group: "type",
customFilter: "http://data.europa.eu/eli/reg_impl/2023/138/oj",
customProperties: [
"http://data.europa.eu/bna/c_ac64a52d",
"http://data.europa.eu/bna/c_dd313021",
"http://data.europa.eu/bna/c_164e0bf5",
"http://data.europa.eu/bna/c_e1da4e07",
"http://data.europa.eu/bna/c_a9135398",
"http://data.europa.eu/bna/c_b79e35eb",
],
showInSearchResult: true,
},
{
Expand Down
8 changes: 7 additions & 1 deletion locales/en/resources.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
{
"http://data.europa.eu/r5r/applicableLegislation": "High-value dataset",
"http://data.europa.eu/bna/c_164e0bf5": "Meteorological data",
"http://data.europa.eu/bna/c_a9135398": "Companies and company ownership",
"http://data.europa.eu/bna/c_ac64a52d": "Geospatial data",
"http://data.europa.eu/bna/c_b79e35eb": "Mobility",
"http://data.europa.eu/bna/c_dd313021": "Earth observation and environment",
"http://data.europa.eu/bna/c_e1da4e07": "Statistics",
"http://data.europa.eu/r5r/hvdCategory": "High-value dataset",
"http://publications.europa.eu/resource/authority/data-theme/AGRI": "Agriculture, fisheries, forestry and food",
"http://publications.europa.eu/resource/authority/data-theme/ECON": "Economy and finance ",
"http://publications.europa.eu/resource/authority/data-theme/EDUC": "Education, culture and sport",
Expand Down
8 changes: 7 additions & 1 deletion locales/sv/resources.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
{
"http://data.europa.eu/r5r/applicableLegislation": "Värdefulla datamängder",
"http://data.europa.eu/bna/c_164e0bf5": "Meteorologiska data",
"http://data.europa.eu/bna/c_a9135398": "Företag och företagsägande",
"http://data.europa.eu/bna/c_ac64a52d": "Geospatiala data",
"http://data.europa.eu/bna/c_b79e35eb": "Rörlighet",
"http://data.europa.eu/bna/c_dd313021": "Jordobservation och miljö",
"http://data.europa.eu/bna/c_e1da4e07": "Statistik",
"http://data.europa.eu/r5r/hvdCategory": "Värdefulla datamängder",
"http://publications.europa.eu/resource/authority/data-theme/AGRI": "Jordbruk, fiske, skogsbruk och livsmedel",
"http://publications.europa.eu/resource/authority/data-theme/ECON": "Ekonomi och finans",
"http://publications.europa.eu/resource/authority/data-theme/EDUC": "Utbildning, kultur och sport",
Expand Down
10 changes: 10 additions & 0 deletions utilities/entrystore/entrystore-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
} from "@entryscape/entrystore-js";
// @ts-expect-error no types
import lucene from "lucene";
import { Translate } from "next-translate";

import { SettingsUtil } from "@/env";
import { Settings_Sandbox } from "@/env/settings.sandbox";
Expand Down Expand Up @@ -81,7 +82,9 @@ export const getEntryLang = (metadataGraph: any, prop: any, lang: string) => {
export const getUriNames = async (
facetValues: string[],
esu: EntryStoreUtil,
t: Translate,
property?: string,
hasCustomProperties?: boolean,
) => {
const cache = entryCache.get();
// Filter out null values and already cached URIs
Expand All @@ -93,6 +96,13 @@ export const getUriNames = async (
return cache;
}

if (hasCustomProperties) {
uniqueUris.forEach((uri) => {
cache.set(uri, t(`resources|${uri}`));
});
return cache;
}

try {
// Load all entries in one batch with a single request
const entries = await esu.loadEntriesByResourceURIs(
Expand Down
24 changes: 16 additions & 8 deletions utilities/entrystore/entrystore.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,10 @@ export class EntrystoreService {
})
.map((v: SearchFacet) => v.name),
this.entryStoreUtil,
this.t,
facetSpec?.dcatProperty,
facetSpec.customProperties &&
facetSpec.customProperties.length > 0,
);
}
}
Expand Down Expand Up @@ -725,21 +728,26 @@ export class EntrystoreService {
for (const facet of customFacets) {
const hasResource = metadata
.find(entry.getResourceURI(), facet.resource)
.some((f: any) =>
f
.getValue()
.startsWith(
.some((f: any) => {
const value = f.getValue();

return (
value.startsWith(
facet?.customFilter?.endsWith("*")
? facet?.customFilter?.slice(0, -1)
: facet?.customFilter || facet?.customProperties?.[0],
),
);
) || facet?.customProperties?.includes(value)
);
});

if (hasResource) {
// Initialize the array if it doesn't exist
values["custom_facet_literal"] =
values["custom_facet_literal"] || [];
// Add the translated resource URI to custom_facet_literal array
values["custom_facet_literal"] = [
values["custom_facet_literal"].push(
this.t(`resources|${facet.resource}`),
];
);
}
}
}
Expand Down
Loading