From 56081c33dad828448c21fa19693adde8fa725d25 Mon Sep 17 00:00:00 2001 From: "argiro.kokogiannaki" Date: Tue, 30 Mar 2021 11:50:15 +0000 Subject: [PATCH] [Library|Trunk] - Cache Interceptor service: add explore home page search queries (stats numbers) - Result Landing: enhance noindex filter (avoid common title/authors/abstract) - Search module: remove unused module git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@60750 d315682c-612b-4755-9ff5-7f18f6832af3 --- cache-interceptor.service.ts | 7 +++++-- .../result/resultLanding.component.ts | 21 ++++++++++++++----- searchPages/find/searchAll.module.ts | 3 +-- .../searchUtils/newSearchPage.component.html | 3 +-- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/cache-interceptor.service.ts b/cache-interceptor.service.ts index 0d863142..93a68c80 100644 --- a/cache-interceptor.service.ts +++ b/cache-interceptor.service.ts @@ -23,7 +23,10 @@ export class CacheInterceptorService implements HttpInterceptor { "/projects/?format=json&refine=true&page=1&size=0&fields=funder", - "/resources/?format=json&query=( oaftype exact datasource )&refine=true&fields=datasourcetypeuiname&fields=country&fields=datasourceodsubjects&fields=datasourceodcontenttypes&fields=datasourcecompatibilityname&&type=datasources&page=0&size=0" + "/resources/?format=json&query=( oaftype exact datasource )&refine=true&fields=datasourcetypeuiname&fields=country&fields=datasourceodsubjects&fields=datasourceodcontenttypes&fields=datasourcecompatibilityname&&type=datasources&page=0&size=0", + + "/search/v2/api/datasources/count?format=json", "/search/v2/api/publications/count?format=json", "/search/v2/api/datasets/count?format=json", "/search/v2/api/software/count?format=json", "/search/v2/api/other/count?format=json", + "relresulttype%3Dpublication" ]; @@ -41,7 +44,7 @@ export class CacheInterceptorService implements HttpInterceptor { } public checkForCachedRequests(url){ - if(url.indexOf("refine=true") !== -1) { + if(url.indexOf("refine=true") !== -1 || url.indexOf("/count?format=json") !== -1 || url.indexOf("relresulttype%3Dpublication") !== -1) { return this.cachingRequests.some(partUrl => (url.indexOf(partUrl) !== -1)); } return false; diff --git a/landingPages/result/resultLanding.component.ts b/landingPages/result/resultLanding.component.ts index f51654b1..33912613 100644 --- a/landingPages/result/resultLanding.component.ts +++ b/landingPages/result/resultLanding.component.ts @@ -641,15 +641,23 @@ export class ResultLandingComponent { || (this.resultLandingInfo.supplementedByResearchResults && this.resultLandingInfo.supplementedByResearchResults.length > 0) ) ); - //words to exclude + //spam words to exclude let title_authors_words = ["movie","hd","film","kimetsu", "1080p","4k","call of duty", "mobile hack", "TUBYDI"]; let abstract_words = ["operacao-feliz-natal.blogspot.com", "moviedouban.site", "hack-expert-solution.link"]; allow = allow && !( - (this.hasKeyword(this.resultLandingInfo.title.toLowerCase(),title_authors_words) || (this.resultLandingInfo.authors && this.hasKeyword(this.resultLandingInfo.authors.join(" ").toLowerCase(),title_authors_words)) - || (this.resultLandingInfo.description && this.hasKeyword(this.resultLandingInfo.description.toLowerCase(),abstract_words)) + (this.hasKeyword(this.resultLandingInfo.title,title_authors_words) || (this.resultLandingInfo.authors && this.hasKeyword(this.resultLandingInfo.authors.map(o => o.fullName).join(" "),title_authors_words)) + || (this.resultLandingInfo.description && this.hasKeyword(this.resultLandingInfo.description,abstract_words)) ) && (this.resultLandingInfo.publisher == "Zenodo" || - this.resultLandingInfo.hostedBy_collectedFrom.filter( value => {return value.downloadName && value.downloadName.toLowerCase().indexOf("zenodo")!=-1}).length > 0)); + this.resultLandingInfo.hostedBy_collectedFrom.filter( value => {return value.downloadName && value.downloadName.indexOf("zenodo")!=-1}).length > 0)); + //common titles/ description / authors + let common_titles = ["introduction", "editorial", "book reviews", "preface", "reviews", "none", "book review", "foreword", "conclusion", "review", "reply","einleitung","short notices","erratum","discussion", "letters to the editor","letter to the editor","reviews of books",":{unav)","editorial board"]; + let common_abstract = ["international audience","n/a","peer reviewed","national audience","info:eu-repo/semantics/published","-",".","graphical abstract","met lit. opg","international audience; no abstract",'.',"politics","info:eu-repo/semantics/publishedversion","copia digital. madrid : ministerio de educación, cultura y deporte, 2016",'',"peer-reviewed","copia digital. madrid : ministerio de educación, cultura y deporte. subdirección general de coordinación bibliotecaria, 2015","-","imperial users only","yüksek lisans"]; + let common_authors = ["[s.n.]","null &na;","nn","(:unap)","(:null)","null anonymous","anonymous"]; + allow = allow && !( + this.isKeyword(this.resultLandingInfo.title,common_titles) || this.isKeyword(this.resultLandingInfo.description,common_abstract) || + (this.resultLandingInfo.authors && this.hasKeyword(this.resultLandingInfo.authors.map(o => o.fullName).join(" "),common_authors)) + ); if(!allow) { this._meta.updateTag({content: 'noindex'}, "name='robots'"); } @@ -660,6 +668,9 @@ export class ResultLandingComponent { } } private hasKeyword(value:string, words:string[]){ - return words.filter( word => { return value.indexOf(word)!=-1}).length > 0; + return words.filter( word => { return value.toLowerCase().indexOf(word)!=-1}).length > 0; + } + private isKeyword(value:string, words:string[]){ + return words.filter( word => { return value.toLowerCase() == word}).length > 0; } } diff --git a/searchPages/find/searchAll.module.ts b/searchPages/find/searchAll.module.ts index e895fc4f..9ca44d3f 100644 --- a/searchPages/find/searchAll.module.ts +++ b/searchPages/find/searchAll.module.ts @@ -10,7 +10,6 @@ import {DataProvidersServiceModule} from '../../services/dataProvidersService.mo import {ProjectsServiceModule} from '../../services/projectsService.module'; import {SearchResearchResultsServiceModule} from '../../services/searchResearchResultsService.module'; import {OrganizationsServiceModule} from '../../services/organizationsService.module'; -import {BrowseEntitiesModule} from '../searchUtils/browseEntities.module'; import {Schema2jsonldModule} from '../../sharedComponents/schema2jsonld/schema2jsonld.module'; import {PiwikServiceModule} from '../../utils/piwik/piwikService.module'; @@ -28,7 +27,7 @@ import {PreviousRouteRecorder} from "../../utils/piwik/previousRouteRecorder.gua CommonModule, FormsModule, RouterModule, DataProvidersServiceModule, ProjectsServiceModule, SearchResearchResultsServiceModule, OrganizationsServiceModule, - BrowseEntitiesModule, SearchResultsModule, PiwikServiceModule, Schema2jsonldModule, SEOServiceModule, AdvancedSearchFormModule, SearchResearchResultsModule, SearchProjectsModule, SearchOrganizationsModule, SearchDataProvidersModule + SearchResultsModule, PiwikServiceModule, Schema2jsonldModule, SEOServiceModule, AdvancedSearchFormModule, SearchResearchResultsModule, SearchProjectsModule, SearchOrganizationsModule, SearchDataProvidersModule ], declarations: [ SearchAllComponent diff --git a/searchPages/searchUtils/newSearchPage.component.html b/searchPages/searchUtils/newSearchPage.component.html index bbb0f296..3bc9c372 100644 --- a/searchPages/searchUtils/newSearchPage.component.html +++ b/searchPages/searchUtils/newSearchPage.component.html @@ -224,8 +224,7 @@ Filters ({{(selectedRangeFilters + selectedFilters)}} - ) + *ngIf="(selectedRangeFilters+selectedFilters) > 0">({{(selectedRangeFilters + selectedFilters)}})