From a7294685fb4ad530d1d1fbca75edd5bb0f691eff Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Thu, 8 Feb 2024 18:05:27 +0200 Subject: [PATCH] [develop | DONE | CHANGED]: refineFieldResults.service.ts & searchDataproviders.service.ts & searchOrganizations.service.ts & searchProjects.service.ts & searchResearchResults.service.ts: Set cache for default refine queries (without keywords or filters) - not in deposit and datasource specific pages. --- services/refineFieldResults.service.ts | 3 ++- services/searchDataproviders.service.ts | 5 +++-- services/searchOrganizations.service.ts | 5 +++-- services/searchProjects.service.ts | 5 +++-- services/searchResearchResults.service.ts | 3 ++- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/services/refineFieldResults.service.ts b/services/refineFieldResults.service.ts index af653a28..0e70a6f6 100644 --- a/services/refineFieldResults.service.ts +++ b/services/refineFieldResults.service.ts @@ -57,7 +57,8 @@ export class RefineFieldResultsService { getField (link:string,fieldName:string, properties:EnvProperties):any{ let url = link+"&refine=true&page=1&size=0"; - return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) + // return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) + return this.http.get((properties.useLongCache && link.includes("sf=") && !link.includes("fq="))? (properties.cacheUrl+encodeURIComponent(url)): url) //.map(res => res.json()) .pipe(map(res => res['refineResults'])) .pipe(map(res => this.parse(res,fieldName))); diff --git a/services/searchDataproviders.service.ts b/services/searchDataproviders.service.ts index 1ae052b5..0277841c 100644 --- a/services/searchDataproviders.service.ts +++ b/services/searchDataproviders.service.ts @@ -47,8 +47,9 @@ export class SearchDataprovidersService { url += "&page="+(page-1)+"&size="+size; url += minRef ? "&minRef=true" : ""; - return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) - .pipe(map(res => [res['meta'].total, this.parseResults(res['results']), RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")])); + // return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) + return this.http.get((properties.useLongCache && size == 0 && !params && (!refineQuery || !refineQuery.includes("fq="))) ? (properties.cacheUrl + encodeURIComponent(url)) : url) + .pipe(map(res => [res['meta'].total, this.parseResults(res['results']), RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")])); } searchDataprovidersForDeposit (id: string,type:string, page: number, size: number, properties:EnvProperties):any { diff --git a/services/searchOrganizations.service.ts b/services/searchOrganizations.service.ts index b71f4e09..488b0e87 100644 --- a/services/searchOrganizations.service.ts +++ b/services/searchOrganizations.service.ts @@ -80,8 +80,9 @@ export class SearchOrganizationsService { url += "&page="+(page-1)+"&size="+size; url += minRef ? "&minRef=true" : ""; - return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) - //.map(res => res.json()) + // return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) + return this.http.get((properties.useLongCache && size == 0 && !params && (!refineQuery || !refineQuery.includes("fq="))) ? (properties.cacheUrl + encodeURIComponent(url)) : url) + //.map(res => res.json()) .pipe(map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "organization")])); } diff --git a/services/searchProjects.service.ts b/services/searchProjects.service.ts index 8e2fa14d..e9c48eaa 100644 --- a/services/searchProjects.service.ts +++ b/services/searchProjects.service.ts @@ -70,8 +70,9 @@ export class SearchProjectsService { url += minRef ? "&minRef=true" : ""; // url += "&format=json"; - return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) - //.map(res => res.json()) + // return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) + return this.http.get((properties.useLongCache && size == 0 && !params && (!refineQuery || !refineQuery.includes("fq="))) ? (properties.cacheUrl + encodeURIComponent(url)) : url) + //.map(res => res.json()) .pipe(map(res => [res['meta'].total, this.parseResults(res['results']), RefineResultsUtils.parse(res['refineResults'],refineFields, "project")])); } diff --git a/services/searchResearchResults.service.ts b/services/searchResearchResults.service.ts index 62329217..d916157a 100644 --- a/services/searchResearchResults.service.ts +++ b/services/searchResearchResults.service.ts @@ -129,7 +129,8 @@ export class SearchResearchResultsService { url += minRef ? "&minRef=true" : ""; // url += "&format=json"; - return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url) + // return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url) + return this.http.get((properties.useLongCache && size == 0 && !params && (!refineQuery || !refineQuery.includes("fq="))) ? (properties.cacheUrl + encodeURIComponent(url)) : url) .pipe(map(res => [res['meta'].total, this.parseResults(resultType, res['results'], properties), RefineResultsUtils.parse(res['refineResults'], refineFields, "publication")])); }