From d9cfca18275d3925c190dce28da6546595f5452e Mon Sep 17 00:00:00 2001 From: Conalb97 Date: Mon, 3 Jun 2024 16:55:54 +0100 Subject: [PATCH] IMAEGEDAM-1675: added to photo sales option on usages@platform chip In order to filter for images that have been sent to photo sales, a new option had to be added to the 'usages@platform' chip - 'Added to Photo Sales'. On the backend, this query had to be mapped to the 'syndication' platform, so that the filter could actually be carried out. A match is used in anticipation of a 'Removed from Photo Sales' option in the future. --- .../js/search/structured-query/query-suggestions.js | 3 +++ media-api/app/lib/elasticsearch/QueryBuilder.scala | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/kahuna/public/js/search/structured-query/query-suggestions.js b/kahuna/public/js/search/structured-query/query-suggestions.js index f17a96d250..1bcc9e870c 100644 --- a/kahuna/public/js/search/structured-query/query-suggestions.js +++ b/kahuna/public/js/search/structured-query/query-suggestions.js @@ -180,6 +180,9 @@ querySuggestions.factory('querySuggestions', ['mediaApi', 'editsApi', function(m if (window._clientConfig.recordDownloadAsUsage === true) { suggestions.push('download'); } + if (window._clientConfig.showSendToPhotoSales) { + suggestions.push('Added to Photo Sales'); + } return suggestions; } diff --git a/media-api/app/lib/elasticsearch/QueryBuilder.scala b/media-api/app/lib/elasticsearch/QueryBuilder.scala index 5f6b07cbfa..96fd6971ff 100644 --- a/media-api/app/lib/elasticsearch/QueryBuilder.scala +++ b/media-api/app/lib/elasticsearch/QueryBuilder.scala @@ -40,8 +40,13 @@ class QueryBuilder(matchFields: Seq[String], overQuotaAgencies: () => List[Agenc case MultipleField(fields) => makeMultiQuery(condition.value, fields) case SingleField(field) => condition.value match { // Force AND operator else it will only require *any* of the words, not *all* - case Words(value) => matchQuery(resolveFieldPath(field), value).operator(Operator.AND) - case Phrase(value) => matchPhraseQuery(resolveFieldPath(field), value) + case Words(value) => + matchQuery(resolveFieldPath(field), value).operator(Operator.AND) + case Phrase(value) => value match { + case "Added to Photo Sales" => + matchPhraseQuery(resolveFieldPath(field), "syndication") + case _ => matchPhraseQuery(resolveFieldPath(field), value) + } case DateRange(start, end) => rangeQuery(resolveFieldPath(field)).gte(printDateTime(start)).lte(printDateTime(end)) case e => throw InvalidQuery(s"Cannot do single field query on $e") }