From 4cd967e541e68ca36d4553cf08bf7d6128595f3b Mon Sep 17 00:00:00 2001 From: Github on behalf of Wellcome Collection Date: Tue, 26 Nov 2024 13:56:39 +0000 Subject: [PATCH] Apply auto-formatting rules --- .../fixtures/TestDocumentFixtures.scala | 1 + .../elasticsearch/ElasticsearchService.scala | 2 ++ .../weco/api/search/models/Aggregation.scala | 4 ++- .../search/services/WorksRequestBuilder.scala | 30 ++++++++++--------- 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/common/search/src/test/scala/weco/api/search/fixtures/TestDocumentFixtures.scala b/common/search/src/test/scala/weco/api/search/fixtures/TestDocumentFixtures.scala index 7ceeeece6..4f3945483 100644 --- a/common/search/src/test/scala/weco/api/search/fixtures/TestDocumentFixtures.scala +++ b/common/search/src/test/scala/weco/api/search/fixtures/TestDocumentFixtures.scala @@ -103,6 +103,7 @@ trait TestDocumentFixtures // With a large number of works this can take a long time // 30 seconds should be enough whenReady(result, Timeout(Span(30, Seconds))) { _ => + println(result) getSizeOf(index) shouldBe documents.size } } diff --git a/search/src/main/scala/weco/api/search/elasticsearch/ElasticsearchService.scala b/search/src/main/scala/weco/api/search/elasticsearch/ElasticsearchService.scala index 5beaed8dc..747cff712 100644 --- a/search/src/main/scala/weco/api/search/elasticsearch/ElasticsearchService.scala +++ b/search/src/main/scala/weco/api/search/elasticsearch/ElasticsearchService.scala @@ -85,6 +85,7 @@ class ElasticsearchService(elasticClient: ElasticClient)(implicit .map(_.toEither) .map { case Right(response) => + println(response) transaction.setLabel("elasticTook", response.took) Right(response) @@ -184,3 +185,4 @@ class ElasticsearchService(elasticClient: ElasticClient)(implicit ) } } + diff --git a/search/src/main/scala/weco/api/search/models/Aggregation.scala b/search/src/main/scala/weco/api/search/models/Aggregation.scala index 1154bf1d5..d81d069c7 100644 --- a/search/src/main/scala/weco/api/search/models/Aggregation.scala +++ b/search/src/main/scala/weco/api/search/models/Aggregation.scala @@ -60,7 +60,8 @@ object AggregationMapping { def aggregationParser( jsonString: String - ): Try[Aggregation] = + ): Try[Aggregation] = { + println(jsonString) parse(jsonString) .map(bucketsFromAnywhere) .toTry @@ -90,6 +91,7 @@ object AggregationMapping { ) }) .map(buckets => Aggregation(buckets.toList)) + } } diff --git a/search/src/main/scala/weco/api/search/services/WorksRequestBuilder.scala b/search/src/main/scala/weco/api/search/services/WorksRequestBuilder.scala index d19931021..128e2eabb 100644 --- a/search/src/main/scala/weco/api/search/services/WorksRequestBuilder.scala +++ b/search/src/main/scala/weco/api/search/services/WorksRequestBuilder.scala @@ -72,12 +72,12 @@ object WorksRequestBuilder filterToQuery = buildWorkFilterQuery ) - /** - * Each aggregatable field is indexed as a nested field with an `id` value and a `label` value. All aggregations - * are `id`-based, with a `label`-based sub-aggregation to get Elasticsearch to return all `label` values associated - * with each `id` bucket. (Usually each `id` value only has one one `label` value associated with it, but not always. - * For example, different Works can use different labels for a given LoC Subject Heading.) - */ + + /** Each aggregatable field is indexed as a nested field with an `id` value and a `label` value. All aggregations + * are `id`-based, with a `label`-based sub-aggregation to get Elasticsearch to return all `label` values associated + * with each `id` bucket. (Usually each `id` value only has one one `label` value associated with it, but not always. + * For example, different Works can use different labels for a given LoC Subject Heading.) + */ private def toIdBasedAggregation( aggregationName: String, nestedFieldPath: String, @@ -88,7 +88,9 @@ object WorksRequestBuilder .field(s"$nestedFieldPath.id") .subAggregations(termsAgg("labels", s"$nestedFieldPath.label").size(1)) - @deprecated("This method is included for backward compatibility reasons and will be removed soon.", "25-10-2024") +// @deprecated( +// "This method is included for backward compatibility reasons and will be removed soon.", +// "25-10-2024") private def toLegacyAggregation( aggregationName: String, aggregatedFieldPath: String, @@ -129,7 +131,8 @@ object WorksRequestBuilder toIdBasedAggregation( "languages", "aggregatableValues.languages", - size = 200) + size = 200 + ) // Note: we want these aggregations to return every possible value, so we // want this to be as many licenses as we support in the catalogue pipeline. @@ -156,12 +159,11 @@ object WorksRequestBuilder ) } - private def dateOrder( - implicit - searchOptions: WorkSearchOptions): Option[SortingOrder] = - searchOptions.sortBy collectFirst { - case ProductionDateSortRequest => - searchOptions.sortOrder + private def dateOrder(implicit + searchOptions: WorkSearchOptions + ): Option[SortingOrder] = + searchOptions.sortBy collectFirst { case ProductionDateSortRequest => + searchOptions.sortOrder } val buildWorkFilterQuery: PartialFunction[WorkFilter, Query] = {