From df4392afcd63b98111165928f14efe83b9724db5 Mon Sep 17 00:00:00 2001 From: Daniele Guido Date: Wed, 16 Aug 2023 10:15:38 +0200 Subject: [PATCH 1/7] use filterWithItems from props --- src/pages/Search.vue | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/pages/Search.vue b/src/pages/Search.vue index 4469e566e..f45f63a8f 100644 --- a/src/pages/Search.vue +++ b/src/pages/Search.vue @@ -212,7 +212,7 @@ import Article from '@/models/Article'; import FacetModel from '@/models/Facet'; import FilterFactory from '@/models/FilterFactory'; import { searchResponseToFacetsExtractor, buildEmptyFacets } from '@/logic/facets'; -import { joinFiltersWithItems, SupportedFiltersByContext } from '@/logic/filters'; +import { SupportedFiltersByContext } from '@/logic/filters'; import { searchQueryGetter, searchQuerySetter, @@ -220,7 +220,6 @@ import { import { search as searchService, searchFacets as searchFacetsService, - filtersItems as filtersItemsService, exporter as exporterService, collectionsItems as collectionsItemsService, } from '@/services'; @@ -231,6 +230,7 @@ const FACET_TYPES_DPFS = [ 'person', 'location', 'topic', + 'nag', ]; const FACET_TYPES_S = [ @@ -259,9 +259,14 @@ export default { paginationTotalRows: 0, /** @type {Facet[]} */ facets: [], - /** @type {Filter[]} */ - filtersWithItems: [], }), + props: { + + filtersWithItems: { + type: Array, + default: () => [], + }, + }, computed: { searchQuery: { ...searchQueryGetter(), @@ -584,7 +589,6 @@ export default { const [ namedEntityFacets, topicFacets, - filtersWithItems, collectionFacets, collectionsItemsIndex, ] = await Promise.all([ @@ -600,12 +604,7 @@ export default { group_by: groupBy, }, }), - filtersItemsService.find({ - query: { - filters: this.searchQueryHash, - }, - }).then(joinFiltersWithItems), - this.isLoggedIn + this.isLoggedIn ? searchFacetsService.get('collection', { query: { filters, @@ -626,7 +625,7 @@ export default { : {}, ]); facets = facets.concat(collectionFacets, namedEntityFacets, topicFacets); - this.filtersWithItems = filtersWithItems; + // this.filtersWithItems = filtersWithItems; // TODO sort facets based on the right order this.facets = facets.map(f => new FacetModel(f)); if (this.isLoggedIn) { From a3b940bb55062885f7498415cf04c586387efa86 Mon Sep 17 00:00:00 2001 From: Daniele Guido Date: Wed, 16 Aug 2023 10:15:54 +0200 Subject: [PATCH 2/7] prepare textreuse page for News agency filter --- src/pages/TextReuse.vue | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pages/TextReuse.vue b/src/pages/TextReuse.vue index bffd49965..0aac884df 100644 --- a/src/pages/TextReuse.vue +++ b/src/pages/TextReuse.vue @@ -138,6 +138,7 @@ const FacetTypes = [ 'language', 'person', 'location', + 'nag', 'textReuseClusterSize', 'textReuseClusterLexicalOverlap', 'textReuseClusterDayDelta', @@ -194,6 +195,7 @@ export default { 'language', 'person', 'location', + // 'nag' ].includes(type), ) }, @@ -344,7 +346,7 @@ export default { }, loadFacet(type, opts = {}) { // eslint-disable-next-line - console.debug('[TextReuse] loadFacet', type, 'query', this.searchFacetApiQueryParams.query) + console.debug('[TextReuse] loadFacet fetching \n - type:', type) // '\n - query', this.searchFacetApiQueryParams.query) searchFacets .get(type, { query: { @@ -354,7 +356,7 @@ export default { }) .then(response => { const facet = this.facets.find(facet => facet.type === type) - console.debug('[TextReuse] loadFacet', response) + console.debug('[TextReuse] loadFacet success \n - type:', type, '\n - ', response) if (facet) { facet.numBuckets = response[0].numBuckets facet.setBuckets(response[0].buckets) @@ -384,6 +386,7 @@ export default { await this.loadFacet('language') await this.loadFacet('person') await this.loadFacet('location') + // await this.loadFacet('nag') }, immediate: true, deep: false, From cacd68fa2fce14c2a894520e1367976560f02532 Mon Sep 17 00:00:00 2001 From: Daniele Guido Date: Wed, 16 Aug 2023 10:15:57 +0200 Subject: [PATCH 3/7] Update messages.js --- src/i18n/messages.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/i18n/messages.js b/src/i18n/messages.js index b043adfec..683a7a6f1 100644 --- a/src/i18n/messages.js +++ b/src/i18n/messages.js @@ -265,6 +265,13 @@ export default { optionsTitle: 'Day of publication', optionsDescription: 'Total number of articles per day', }, + nag: { + title: 'News Agency | News Agency | News Agencies', + optionsTitle: 'News Agency', + filterTitle: 'filter by News Agency', + optionsDescription: 'Total number of articles per News Agency', + empty: 'No news agency available', + }, type: { title: 'Article content type | Article content types | Article content types', optionsTitle: 'Article content type', From e57b2af042be1e8eb440d1ad95acdf665e31e07f Mon Sep 17 00:00:00 2001 From: Daniele Guido Date: Wed, 16 Aug 2023 10:15:59 +0200 Subject: [PATCH 4/7] Update TheHeader.vue --- src/components/TheHeader.vue | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/components/TheHeader.vue b/src/components/TheHeader.vue index 49be6f86d..0d80ce8c8 100644 --- a/src/components/TheHeader.vue +++ b/src/components/TheHeader.vue @@ -61,19 +61,12 @@ > {{ $t('label_compare') }} - - {{ $t('label_text_reuse') }} - - {{ $t('label_text_reuse_star') }} + {{ $t('label_text_reuse') }} Date: Wed, 16 Aug 2023 10:16:16 +0200 Subject: [PATCH 5/7] use new impresso-jscommons with nag types --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7a2b467f8..1de411e6c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,7 +21,7 @@ "filepond-plugin-file-validate-size": "2.2.0", "filepond-plugin-file-validate-type": "1.2.4", "flatpickr": "4.6.3", - "impresso-jscommons": "git+https://git@github.com/impresso/impresso-jscommons.git#v1.3.1", + "impresso-jscommons": "git+https://git@github.com/impresso/impresso-jscommons.git#v1.4.1", "impresso-theme": "git+https://git@github.com/impresso/impresso-theme.git", "markdown-it": "12.3.2", "markdown-it-decorate": "1.2.2", @@ -53260,7 +53260,7 @@ "impresso-jscommons": { "version": "git+https://git@github.com/impresso/impresso-jscommons.git#56062a4ac2b351fba8d1efdd826de5274e1b2676", "integrity": "sha512-EnoxM7XqFKo3Z7bDkaLNNndeo8waPjcXwF3YcIyBYG+hlxRl8m0nwCR9Mwt0WiKrCuwCX3aR7GELnyeWHzW6Hg==", - "from": "impresso-jscommons@git+https://git@github.com/impresso/impresso-jscommons.git#v1.3.1", + "from": "impresso-jscommons@git+https://git@github.com/impresso/impresso-jscommons.git#v1.4.1", "requires": { "base64-js": "1.3.1", "case": "1.6.2", diff --git a/package.json b/package.json index 8d3199240..67cbb1189 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "filepond-plugin-file-validate-size": "2.2.0", "filepond-plugin-file-validate-type": "1.2.4", "flatpickr": "4.6.3", - "impresso-jscommons": "git+https://git@github.com/impresso/impresso-jscommons.git#v1.3.1", + "impresso-jscommons": "git+https://git@github.com/impresso/impresso-jscommons.git#v1.4.1", "impresso-theme": "git+https://git@github.com/impresso/impresso-theme.git", "markdown-it": "12.3.2", "markdown-it-decorate": "1.2.2", From 12a014e4b919223ebe5f61fc48a203c68f01af8b Mon Sep 17 00:00:00 2001 From: Daniele Guido Date: Wed, 16 Aug 2023 11:10:34 +0200 Subject: [PATCH 6/7] add NAG in pissla and in the list of stuff --- src/components/SearchPills.vue | 8 +++- src/i18n/messages.js | 4 ++ src/logic/filters.js | 1 + src/models/FilterFactory.js | 2 +- src/pages/Search.vue | 73 ++++++++++++++++------------------ 5 files changed, 46 insertions(+), 42 deletions(-) diff --git a/src/components/SearchPills.vue b/src/components/SearchPills.vue index 148a4c278..376ef3771 100644 --- a/src/components/SearchPills.vue +++ b/src/components/SearchPills.vue @@ -30,7 +30,8 @@ { 'dripicons-pulse': filter.type === 'daterange' }, { 'dripicons-calendar': filter.type === 'year' }, { 'dripicons-suitcase': filter.type === 'collection' }, - { 'dripicons-tag': filter.type === 'type' }, + { 'dripicons-tag': filter.type === 'type' }, + { 'dripicons-print': filter.type === 'country' }, { 'dripicons-shopping-bag': filter.type === 'accessRight' }, { 'dripicons-store': filter.type === 'partner' }, @@ -60,7 +61,7 @@ @@ -540,6 +541,9 @@ export default { "location": { "title": "filter by location (experimental)" }, + "nag": { + "title": "filter by News Agency" + }, "collection": { "title": "filter by collection" }, diff --git a/src/i18n/messages.js b/src/i18n/messages.js index 683a7a6f1..9bca76a4b 100644 --- a/src/i18n/messages.js +++ b/src/i18n/messages.js @@ -271,6 +271,10 @@ export default { filterTitle: 'filter by News Agency', optionsDescription: 'Total number of articles per News Agency', empty: 'No news agency available', + context: { + include: 'written by', + exclude: 'NOT written by', + }, }, type: { title: 'Article content type | Article content types | Article content types', diff --git a/src/logic/filters.js b/src/logic/filters.js index c49472247..88a172eaa 100644 --- a/src/logic/filters.js +++ b/src/logic/filters.js @@ -162,6 +162,7 @@ export const SupportedFiltersByContext = Object.freeze({ 'entity', 'person', 'location', + 'nag', 'topicmodel', 'topic-string', 'entity-string', diff --git a/src/models/FilterFactory.js b/src/models/FilterFactory.js index e48e808d2..b4f7544f6 100644 --- a/src/models/FilterFactory.js +++ b/src/models/FilterFactory.js @@ -44,7 +44,7 @@ export default { filter = new FilterRegex(filterData) } - if (['entity', 'person', 'location'].indexOf(filterData.type) !== -1) { + if (['entity', 'person', 'location', 'nag'].indexOf(filterData.type) !== -1) { filter = new FilterEntity(filterData) } diff --git a/src/pages/Search.vue b/src/pages/Search.vue index f45f63a8f..e5e972378 100644 --- a/src/pages/Search.vue +++ b/src/pages/Search.vue @@ -258,7 +258,7 @@ export default { searchResults: [], paginationTotalRows: 0, /** @type {Facet[]} */ - facets: [], + facets: [] }), props: { @@ -586,50 +586,42 @@ export default { this.searchResults = data.map(d => new Article(d)); let facets = searchResponseToFacetsExtractor(FACET_TYPES_S)({ info }); // get remaining facets and enriched filters. - const [ - namedEntityFacets, - topicFacets, - collectionFacets, - collectionsItemsIndex, - ] = await Promise.all([ - searchFacetsService.get('person,location', { + const namedEntityFacets = await searchFacetsService.get('person,location', { + query: { + filters, + group_by: groupBy, + }, + }); + const topicFacets = await searchFacetsService.get('topic', { + query: { + filters, + group_by: groupBy, + }, + }); + const nagFacets = await searchFacetsService.get('nag', { + query: { + filters, + group_by: groupBy, + }, + }); + facets = facets.concat(namedEntityFacets, topicFacets, nagFacets); + if(this.isLoggedIn) { + const collectionFacets = await searchFacetsService.get('collection', { query: { filters, group_by: groupBy, }, - }), - searchFacetsService.get('topic', { + }); + facets = facets.concat(collectionFacets); + const collectionsItemsIndex = await collectionsItemsService.find({ query: { - filters, - group_by: groupBy, + item_uids: this.searchResults.map(d => d.uid), + limit: 100, }, - }), - this.isLoggedIn - ? searchFacetsService.get('collection', { - query: { - filters, - group_by: groupBy, - }, - }) - : [], - this.isLoggedIn - ? collectionsItemsService.find({ - query: { - item_uids: this.searchResults.map(d => d.uid), - limit: 100, - }, - }).then(({ data }) => data.reduce((acc, d) => { - acc[d.itemId] = d; - return acc; - }, {})) - : {}, - ]); - facets = facets.concat(collectionFacets, namedEntityFacets, topicFacets); - // this.filtersWithItems = filtersWithItems; - // TODO sort facets based on the right order - this.facets = facets.map(f => new FacetModel(f)); - if (this.isLoggedIn) { - // add collections. + }).then(({ data }) => data.reduce((acc, d) => { + acc[d.itemId] = d; + return acc; + }, {})); this.searchResults = this.searchResults.map((article) => { if (collectionsItemsIndex[article.uid]) { article.collections = collectionsItemsIndex[article.uid].collections; @@ -637,6 +629,9 @@ export default { return article; }); } + + + this.facets = facets.map(f => new FacetModel(f)); }, immediate: true, }, From ad04b62cf77bfd00989e64656dba5997ef0189f5 Mon Sep 17 00:00:00 2001 From: Daniele Guido Date: Wed, 16 Aug 2023 11:30:30 +0200 Subject: [PATCH 7/7] add to search query summary --- src/components/modules/SearchQuerySummary.vue | 4 ++++ src/components/modules/SearchResultsListItem.vue | 2 +- src/components/modules/lists/ItemLabel.vue | 3 +++ src/i18n/messages.js | 1 + src/models/Entity.js | 4 ++++ 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/components/modules/SearchQuerySummary.vue b/src/components/modules/SearchQuerySummary.vue index d31262b1b..4fb107ca7 100644 --- a/src/components/modules/SearchQuerySummary.vue +++ b/src/components/modules/SearchQuerySummary.vue @@ -25,6 +25,7 @@ export default { 'topic', 'person', 'location', + 'nag', 'language', 'country', 'year', @@ -156,6 +157,7 @@ export default { case 'location': case 'person': case 'collection': + case 'nag': t = item.name break case 'newspaper': @@ -355,6 +357,7 @@ export default { "newspaper": "published in", "person": "mentioning", "location": "mentioning", + "nag": "gathered by", "string": "containing", "title": "where title includes", "daterange": "published", @@ -382,6 +385,7 @@ export default { "newspaper": "not published in", "person": "not mentioning", "location": "not mentioning", + "nag": "not gathered by", "string": "not containing", "title": "where title does not include", "daterange": "not published", diff --git a/src/components/modules/SearchResultsListItem.vue b/src/components/modules/SearchResultsListItem.vue index e2bef9a22..0d0880109 100644 --- a/src/components/modules/SearchResultsListItem.vue +++ b/src/components/modules/SearchResultsListItem.vue @@ -1,4 +1,4 @@ -