From 35ab590c27ffc9fecb21babf5fa360c2cb25377f Mon Sep 17 00:00:00 2001 From: Jeremy Prevost Date: Fri, 8 Jan 2021 11:51:07 -0500 Subject: [PATCH 1/2] Updates returned order of aggregations Why are these changes being introduced: * The order was rather arbitrary to begin with, and we decided to make the order match at least one real world use case, which is our own DISCO UI Relevant ticket(s): * https://mitlibraries.atlassian.net/browse/DISCO-221 How does this address that need: * This returns the aggregations in the order our DISCO UI currently desires. Future changes to the display order in any UI should probably be handled in the UI itself, but since the initial order was not for a specific purpose this was both easier and fine. --- .../api/v1/search/_aggregations.json.jbuilder | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/app/views/api/v1/search/_aggregations.json.jbuilder b/app/views/api/v1/search/_aggregations.json.jbuilder index a59b099d..4a63b90e 100644 --- a/app/views/api/v1/search/_aggregations.json.jbuilder +++ b/app/views/api/v1/search/_aggregations.json.jbuilder @@ -1,14 +1,12 @@ json.aggregations do - json.language @results['aggregations']['languages']['buckets'] do |x| + json.source @results['aggregations']['source']['buckets'] do |x| json.name x['key'] json.count x['doc_count'] end - if @results['aggregations']['collections'] - json.collection @results['aggregations']['collections']['buckets'] do |x| - json.name x['key'] - json.count x['doc_count'] - end + json.content_format @results['aggregations']['content_format']['buckets'] do |x| + json.name x['key'] + json.count x['doc_count'] end json.content_type @results['aggregations']['content_type']['buckets'] do |x| @@ -16,6 +14,13 @@ json.aggregations do json.count x['doc_count'] end + if @results['aggregations']['collections'] + json.collection @results['aggregations']['collections']['buckets'] do |x| + json.name x['key'] + json.count x['doc_count'] + end + end + json.contributor @results['aggregations']['contributors']['contributor_names']['buckets'] do |x| json.name x['key'] json.count x['doc_count'] @@ -26,7 +31,7 @@ json.aggregations do json.count x['doc_count'] end - json.content_format @results['aggregations']['content_format']['buckets'] do |x| + json.language @results['aggregations']['languages']['buckets'] do |x| json.name x['key'] json.count x['doc_count'] end @@ -35,9 +40,4 @@ json.aggregations do json.name x['key'] json.count x['doc_count'] end - - json.source @results['aggregations']['source']['buckets'] do |x| - json.name x['key'] - json.count x['doc_count'] - end end From a70c5dd879c15e41af3625547c9f1edce6e60f1e Mon Sep 17 00:00:00 2001 From: Jeremy Prevost Date: Fri, 8 Jan 2021 11:56:05 -0500 Subject: [PATCH 2/2] update nokogiri --- Gemfile.lock | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index d7fb17b8..2fa9a63a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -145,7 +145,7 @@ GEM method_source (1.0.0) mimemagic (0.3.5) mini_mime (1.0.2) - mini_portile2 (2.4.0) + mini_portile2 (2.5.0) minitest (5.14.2) mitlibraries-theme (0.4.0) rails (~> 5) @@ -155,8 +155,9 @@ GEM multi_json (1.14.1) multipart-post (2.1.1) nio4r (2.5.4) - nokogiri (1.10.10) - mini_portile2 (~> 2.4.0) + nokogiri (1.11.1) + mini_portile2 (~> 2.5.0) + racc (~> 1.4) orm_adapter (0.5.0) parallel (1.20.1) parser (2.7.2.0) @@ -165,6 +166,7 @@ GEM public_suffix (4.0.6) puma (5.1.0) nio4r (~> 2.0) + racc (1.5.2) rack (2.2.3) rack-attack (6.3.1) rack (>= 1.0, < 3)