From bca624d65877b036e0f00fbdeb364958ce0f4c0e Mon Sep 17 00:00:00 2001 From: j-corry Date: Thu, 26 Sep 2024 15:40:47 +0100 Subject: [PATCH] - Add a check for SES before any controller action, so that we can just show a 500 page if it's down - Add a custom primary member facet (the lead, tabling and asking member facets remain enabled for testing purposes for the time being) --- app/controllers/application_controller.rb | 16 + app/helpers/application_helper.rb | 5 +- app/models/hierarchy_builder.rb | 5 +- app/models/search_data.rb | 18 +- app/models/ses_lookup.rb | 48 +- app/models/solr_search.rb | 16 + app/views/search/index.html.erb | 4 +- coverage/.last_run.json | 2 +- coverage/.resultset.json | 135 +- coverage/index.html | 1883 ++++++++++++++------- spec/models/ses_lookup_spec.rb | 6 +- 11 files changed, 1478 insertions(+), 660 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 09705d12..978b173a 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,2 +1,18 @@ class ApplicationController < ActionController::Base + + before_action :check_api_status + + def check_api_status + # Make a simple SES request to check the service is working + # This is skipped during tests + + unless Rails.env.test? + check = SesLookup.new([{ value: 346696 }]).test_api_response + + if check.has_key?("error") + render template: "layouts/shared/error/500", locals: { status: check.dig("error", "errorType"), message: check.dig("error", "errorMessage") } + end + end + end + end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e51085f7..68c6d11a 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -106,9 +106,12 @@ def filter_field_name(field) department_t: 'Department', year: 'Date', month: 'Date', - session: 'Session' + session: 'Session', + primaryMember_ses: 'Primary member' } + raise "Unknown field name '#{field}'" if Rails.env.development? && !field_names.keys.include?(field.to_sym) + field_names[field.to_sym] end diff --git a/app/models/hierarchy_builder.rb b/app/models/hierarchy_builder.rb index 229fd1ba..fe2d5627 100644 --- a/app/models/hierarchy_builder.rb +++ b/app/models/hierarchy_builder.rb @@ -16,7 +16,7 @@ def hierarchy_data def formatted_ses_data ret = {} - ses_data.keys.each {|a| ret[a.first] = a.last } + ses_data.keys.each { |a| ret[a.first] = a.last } ret end @@ -49,7 +49,10 @@ def organise_hierarchy_data(ses_data) def top_level_types return unless ses_data.is_a?(Hash) + return [] if ses_data.has_key?("error") + ret = [] + # select types that have 'Content Type' as their parent ses_data.select { |k, v| v.first.dig("fields").first.dig("field", "id") == "346696" }.keys.map do |id, name| ret << { id: id, name: name } diff --git a/app/models/search_data.rb b/app/models/search_data.rb index 85fb624d..5ec65453 100644 --- a/app/models/search_data.rb +++ b/app/models/search_data.rb @@ -250,7 +250,7 @@ def facets facet_field_data.slice("type_sesrollup", "legislature_ses", "date_dt", "department_ses", "member_ses", "tablingMember_ses", "askingMember_ses", "leadMember_ses", "answeringMember_ses", "legislativeStage_ses", "legislationTitle_ses", "subject_ses", - "topic_ses", "year", "publisher_ses").map { |k, v| { field_name: k, facets: sort_facets(v['buckets']) } } + "topic_ses", "year", "publisher_ses", "primaryMember_ses").map { |k, v| { field_name: k, facets: sort_facets(v['buckets']) } } end def type_facets @@ -268,6 +268,22 @@ def session_facets facet_field_data.select { |field| field.split('_').first == "session" } end + def primary_member_facets + return [] unless search + + facet_field_data = search.dig(:data, 'facets') + return [] if facet_field_data.blank? + + ret = [] + facet_field_data.dig("primaryMember_ses", "buckets").each do |bucket| + bucket.dig("unique_combined", "buckets").each do |sub_bucket| + ret << sub_bucket + end + end + + ret + end + def sort_facets(facet_field) facet_field.sort_by { |h| h["count"] }.reverse end diff --git a/app/models/ses_lookup.rb b/app/models/ses_lookup.rb index e033d267..dcb047ff 100644 --- a/app/models/ses_lookup.rb +++ b/app/models/ses_lookup.rb @@ -45,18 +45,11 @@ def evaluated_responses # fetch response response = api_response(uri) - # try to parse the response as JSON & extract terms - begin - parsed_response = JSON.parse(response) - evaluated = parsed_response.dig('terms') - rescue JSON::ParserError - # contrary to SES API documentation, errors seem to be returned as XML regardless of specified TEMPLATE - evaluated = Hash.from_xml(response) - puts "Error: #{evaluated}" if Rails.env.development? - end - - # collate responses - output << evaluated + # extract terms + terms = response.dig('terms') + + # collate terms from all responses + output << terms end end @@ -70,8 +63,12 @@ def evaluated_responses def evaluated_hierarchy_response uri = ses_browse_service_uri - response = JSON.parse(api_response(uri)) - response.dig("terms") + api_response(uri) + end + + def test_api_response + uri = ses_term_service_uri("346696") + api_response(uri) end def data @@ -108,14 +105,15 @@ def extract_hierarchy_data # the hashes contain a nested 'term' hash containing 'id' and 'name' # If SES returns an error, we'll get an error key returned from evaluated_response - return responses.first if responses.first&.has_key?(:error) + return responses if responses.has_key?("error") - unless responses.compact.blank? - responses.each do |response| + terms = responses.dig('terms') + unless terms.compact.blank? + terms.each do |term| new_key = [] - new_key << response.dig('term', 'id')&.to_i - new_key << response.dig('term', 'name') - ret[new_key] = response.dig('term', 'hierarchy') + new_key << term.dig('term', 'id')&.to_i + new_key << term.dig('term', 'name') + ret[new_key] = term.dig('term', 'hierarchy') end end @@ -139,6 +137,14 @@ def group_size def api_response(uri) raise 'Please stub this method to avoid HTTP requests in test environment' if Rails.env.test? - api_get_request(uri) + raw_response = api_get_request(uri) + + begin + JSON.parse(raw_response) + rescue JSON::ParserError + # contrary to SES API documentation, errors seem to be returned as XML regardless of specified TEMPLATE + evaluated_as_xml = Hash.from_xml(raw_response) + puts "Error: #{evaluated_as_xml}" if Rails.env.development? + end end end \ No newline at end of file diff --git a/app/models/solr_search.rb b/app/models/solr_search.rb index 82538409..c5cd5d17 100644 --- a/app/models/solr_search.rb +++ b/app/models/solr_search.rb @@ -272,6 +272,22 @@ def facet_hash } end + ret['primaryMember_ses'] = { + "type": "terms", + "field": "askingMember_ses", + "limit": 80, + "facet": { + "unique_combined": { + "type": "terms", + "field": "leadMember_ses", + "limit": -1, + "facet": { + "unique_count": "unique(askingMember_ses)" + } + } + } + } + ret.to_json end diff --git a/app/views/search/index.html.erb b/app/views/search/index.html.erb index 6bab9df7..1137cf7f 100644 --- a/app/views/search/index.html.erb +++ b/app/views/search/index.html.erb @@ -11,10 +11,10 @@ <%#= render 'search/fragments/data', data: @search_data.search, title: 'Search response' %> <%#= render 'search/fragments/data', data: @ses_data, title: 'SES results' %> <%#= render 'search/fragments/data', data: @search_data.facets, title: 'Facets' %> + <%#= render 'search/fragments/data', data: @search_data.primary_member_facets, title: 'Primary Member Facets' %> <%#= render 'search/fragments/data', data: @search_data.type_facets, title: 'Type facets' %> <%#= render 'search/fragments/data', data: @search_data.hierarchy_data, title: 'Hierarchy data' %> <%#= render 'search/fragments/data', data: @top_level, title: 'Hierarchy top level types' %> - <%#= render 'search/fragments/data', data: @toggled_facets, title: 'Toggled facets' %> <%#= render 'search/fragments/data', data: request.params, title: 'All params' %> <% end %> @@ -53,7 +53,7 @@ <% end %> <%= render 'search/results/facets/date_facet' %> <%= render 'search/results/facets/session_facet', facet_data: @search_data.session_facets %> - <% @search_data.facets.select { |h| ["session_t", "department_ses", "member_ses", "tablingMember_ses", "askingMember_ses", "leadMember_ses", "answeringMember_ses", "legislativeStage_ses", "legislationTitle_ses", "subject_ses", "publisher_ses"].include?(h.dig(:field_name)) }.each do |facet_field| %> + <% @search_data.facets.select { |h| ["session_t", "department_ses", "member_ses", "primaryMember_ses", "tablingMember_ses", "askingMember_ses", "leadMember_ses", "answeringMember_ses", "legislativeStage_ses", "legislationTitle_ses", "subject_ses", "publisher_ses"].include?(h.dig(:field_name)) }.each do |facet_field| %> <%= render 'filter_section', facet_field: format_facets(facet_field) %> <% end %> diff --git a/coverage/.last_run.json b/coverage/.last_run.json index 2cabc523..e956e134 100644 --- a/coverage/.last_run.json +++ b/coverage/.last_run.json @@ -1,5 +1,5 @@ { "result": { - "line": 81.51 + "line": 80.73 } } diff --git a/coverage/.resultset.json b/coverage/.resultset.json index f59cde99..0bd2659d 100644 --- a/coverage/.resultset.json +++ b/coverage/.resultset.json @@ -20,6 +20,22 @@ "/Users/jon.corry/RubymineProjects/search-prototype/app/controllers/application_controller.rb": { "lines": [ 1, + null, + 1, + null, + 1, + null, + null, + null, + 212, + 0, + null, + 0, + 0, + null, + null, + null, + null, null ] }, @@ -32,6 +48,7 @@ null, null, 1, + 1, null, 1, 103, @@ -135,6 +152,9 @@ null, null, null, + null, + 2, + null, 2, null, null, @@ -162,7 +182,7 @@ 1, null, null, - 132, + 264, null, null, 1, @@ -172,7 +192,7 @@ null, null, 1, - 3, + 6, null, null ] @@ -188,6 +208,14 @@ null, 258, null, + null, + 1, + 0, + null, + 0, + null, + 0, + null, null ] }, @@ -406,12 +434,6 @@ null ] }, - "/Users/jon.corry/RubymineProjects/search-prototype/app/helpers/meta_helper.rb": { - "lines": [ - 1, - null - ] - }, "/Users/jon.corry/RubymineProjects/search-prototype/app/helpers/search_helper.rb": { "lines": [ 1, @@ -2044,15 +2066,18 @@ null, null, 1, - 3, + 6, null, - 3, + 6, null, 6, + null, + null, + 12, 0, null, null, - 3, + 6, null, null ] @@ -2969,8 +2994,8 @@ null, null, 1, - 5, - 5, + 8, + 8, null, 3, null, @@ -3023,15 +3048,15 @@ null, null, 1, - 15, + 21, null, - 14, - 14, + 20, + 20, null, - 14, + 20, null, null, - 18, + 24, null, null, 1, @@ -3041,28 +3066,44 @@ null, null, 1, - 3, + 6, null, - 3, - 3, + 6, + 6, null, - 9, + 18, null, null, 1, - 54, + 0, + null, + 0, + 0, + null, + 0, + 0, + 0, + 0, + null, + null, + null, + 0, null, null, 1, - 6, + 72, null, null, 1, - 8, + 9, null, - 6, null, - 6, + 1, + 11, + null, + 9, + null, + 9, null, 9, null, @@ -3119,14 +3160,7 @@ 2, null, null, - null, 2, - 2, - null, - null, - 0, - 0, - null, null, null, 2, @@ -3144,6 +3178,10 @@ 1, 0, 0, + null, + null, + 1, + 0, 0, null, null, @@ -3189,6 +3227,7 @@ 0, 0, 0, + 0, null, null, null, @@ -3214,6 +3253,14 @@ null, 0, null, + null, + 0, + null, + null, + 0, + 0, + null, + null, null ] }, @@ -3575,6 +3622,22 @@ 0, null, null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 0, + null, + null, 1, 0, 0, @@ -3600,7 +3663,7 @@ null, 1, null, - 9, + 18, null, null, null, @@ -3915,6 +3978,6 @@ ] } }, - "timestamp": 1726567988 + "timestamp": 1727360672 } } diff --git a/coverage/index.html b/coverage/index.html index f695a1cb..a83a2d66 100644 --- a/coverage/index.html +++ b/coverage/index.html @@ -14,7 +14,7 @@ loading
-
Generated 2024-09-17T11:13:08+01:00
+
Generated 2024-09-26T15:24:32+01:00
@@ -23,14 +23,14 @@

All Files ( - 81.51% + 80.73% covered at - 87.66 + 86.66 hits/line ) @@ -39,15 +39,15 @@

- 71 files in total. + 70 files in total.
- 1693 relevant lines, - 1380 lines covered and - 313 lines missed. + 1718 relevant lines, + 1387 lines covered and + 331 lines missed. ( - 81.51% + 80.73% )
@@ -94,12 +94,12 @@

app/controllers/application_controller.rb - 100.00 % - 2 - 1 - 1 - 0 - 1.00 + 57.14 % + 18 + 7 + 4 + 3 + 30.71 @@ -138,23 +138,23 @@

app/helpers/application_helper.rb - 79.63 % - 150 - 54 - 43 + 80.36 % + 154 + 56 + 45 11 - 24.94 + 26.52 app/helpers/date_helper.rb - 100.00 % - 10 - 5 - 5 - 0 - 156.20 + 66.67 % + 18 + 9 + 6 + 3 + 86.89 @@ -180,17 +180,6 @@

- - app/helpers/meta_helper.rb - 100.00 % - 2 - 1 - 1 - 0 - 1.00 - - - app/helpers/search_helper.rb 100.00 % @@ -435,12 +424,12 @@

app/models/hierarchy_builder.rb - 81.82 % - 60 - 33 - 27 + 82.35 % + 63 + 34 + 28 6 - 5.06 + 5.53 @@ -721,23 +710,23 @@

app/models/search_data.rb - 90.48 % - 288 - 147 - 133 - 14 - 9.21 + 85.90 % + 304 + 156 + 134 + 22 + 9.22 app/models/ses_lookup.rb - 71.21 % - 144 - 66 + 68.12 % + 150 + 69 47 - 19 - 23.89 + 22 + 22.84 @@ -776,12 +765,12 @@

app/models/solr_search.rb - 37.69 % - 363 - 130 + 37.40 % + 379 + 131 49 - 81 - 2.59 + 82 + 2.64 @@ -1022,8 +1011,8 @@

app/controllers/application_controller.rb

- - 100.0% + + 57.14% lines covered @@ -1032,9 +1021,9 @@

- 1 relevant lines. - 1 lines covered and - 0 lines missed. + 7 relevant lines. + 4 lines covered and + 3 lines missed.
@@ -1062,6 +1051,182 @@

+ + +

+ +
+
  • + 1 + + + + + before_action :check_api_status +
  • +
    + +
    +
  • + + + + + + +
  • +
    + +
    +
  • + 1 + + + + + def check_api_status +
  • +
    + +
    +
  • + + + + + + # Make a simple SES request to check the service is working +
  • +
    + +
    +
  • + + + + + + # This is skipped during tests +
  • +
    + +
    +
  • + + + + + + +
  • +
    + +
    +
  • + 212 + + + + + unless Rails.env.test? +
  • +
    + +
    +
  • + + + + + + check = SesLookup.new([{ value: 346696 }]).test_api_response +
  • +
    + +
    +
  • + + + + + + +
  • +
    + +
    +
  • + + + + + + if check.has_key?("error") +
  • +
    + +
    +
  • + + + + + + render template: "layouts/shared/error/500", locals: { status: check.dig("error", "errorType"), message: check.dig("error", "errorMessage") } +
  • +
    + +
    +
  • + + + + + + end +
  • +
    + +
    +
  • + + + + + + end +
  • +
    + +
    +
  • + + + + + + end +
  • +
    + +
    +
  • + + + + + + +
  • +
    + +
    +
  • + + + + + end
  • @@ -2378,8 +2543,8 @@

    app/helpers/application_helper.rb

    - - 79.63% + + 80.36% lines covered @@ -2388,8 +2553,8 @@

    - 54 relevant lines. - 43 lines covered and + 56 relevant lines. + 45 lines covered and 11 lines missed.
    @@ -2473,12 +2638,23 @@

    - DATE_DISPLAY_FORMAT = '%A, %e %B %Y' + DATE_FORMAT_WITH_DAY = '%A, %e %B %Y'

    -
  • +
  • + 1 + + + + + DATE_FORMAT_WITHOUT_DAY = '%e %B %Y' +
  • +
    + +
    +
  • @@ -2489,7 +2665,7 @@

  • -
  • +
  • 1 @@ -2500,7 +2676,7 @@

  • -
  • +
  • 103 @@ -2511,7 +2687,7 @@

  • -
  • +
  • 101 @@ -2522,7 +2698,7 @@

  • -
  • +
  • @@ -2533,7 +2709,7 @@

  • -
  • +
  • 2 @@ -2544,7 +2720,7 @@

  • -
  • +
  • @@ -2555,7 +2731,7 @@

  • -
  • +
  • @@ -2566,7 +2742,7 @@

  • -
  • +
  • @@ -2577,7 +2753,7 @@

  • -
  • +
  • 1 @@ -2588,7 +2764,7 @@

  • -
  • +
  • @@ -2599,7 +2775,7 @@

  • -
  • +
  • @@ -2610,7 +2786,7 @@

  • -
  • +
  • @@ -2621,7 +2797,7 @@

  • -
  • +
  • 72 @@ -2632,7 +2808,7 @@

  • -
  • +
  • @@ -2643,7 +2819,7 @@

  • -
  • +
  • 2 @@ -2654,7 +2830,7 @@

  • -
  • +
  • @@ -2665,7 +2841,7 @@

  • -
  • +
  • @@ -2676,7 +2852,7 @@

  • -
  • +
  • 1 @@ -2687,7 +2863,7 @@

  • -
  • +
  • 12 @@ -2698,7 +2874,7 @@

  • -
  • +
  • @@ -2709,7 +2885,7 @@

  • -
  • +
  • 1 @@ -2720,7 +2896,7 @@

  • -
  • +
  • @@ -2731,7 +2907,7 @@

  • -
  • +
  • 3 @@ -2742,7 +2918,7 @@

  • -
  • +
  • @@ -2753,7 +2929,7 @@

  • -
  • +
  • 1 @@ -2764,7 +2940,7 @@

  • -
  • +
  • @@ -2775,7 +2951,7 @@

  • -
  • +
  • 1 @@ -2786,7 +2962,7 @@

  • -
  • +
  • @@ -2797,7 +2973,7 @@

  • -
  • +
  • 1 @@ -2808,7 +2984,7 @@

  • -
  • +
  • @@ -2819,7 +2995,7 @@

  • -
  • +
  • 1 @@ -2830,7 +3006,7 @@

  • -
  • +
  • @@ -2841,7 +3017,7 @@

  • -
  • +
  • 1 @@ -2852,7 +3028,7 @@

  • -
  • +
  • @@ -2863,7 +3039,7 @@

  • -
  • +
  • 1 @@ -2874,7 +3050,7 @@

  • -
  • +
  • @@ -2885,7 +3061,7 @@

  • -
  • +
  • 1 @@ -2896,7 +3072,7 @@

  • -
  • +
  • @@ -2907,7 +3083,7 @@

  • -
  • +
  • 1 @@ -2918,7 +3094,7 @@

  • -
  • +
  • @@ -2929,7 +3105,7 @@

  • -
  • +
  • @@ -2940,7 +3116,7 @@

  • -
  • +
  • @@ -2951,7 +3127,7 @@

  • -
  • +
  • 1 @@ -2962,7 +3138,7 @@

  • -
  • +
  • 435 @@ -2973,7 +3149,7 @@

  • -
  • +
  • @@ -2984,7 +3160,7 @@

  • -
  • +
  • @@ -2995,7 +3171,7 @@

  • -
  • +
  • 427 @@ -3006,7 +3182,7 @@

  • -
  • +
  • @@ -3017,7 +3193,7 @@

  • -
  • +
  • @@ -3028,7 +3204,7 @@

  • -
  • +
  • 6 @@ -3039,7 +3215,7 @@

  • -
  • +
  • 6 @@ -3050,7 +3226,7 @@

  • -
  • +
  • @@ -3061,7 +3237,7 @@

  • -
  • +
  • 4 @@ -3072,7 +3248,7 @@

  • -
  • +
  • 4 @@ -3083,7 +3259,7 @@

  • -
  • +
  • @@ -3094,7 +3270,7 @@

  • -
  • +
  • 4 @@ -3105,7 +3281,7 @@

  • -
  • +
  • @@ -3116,7 +3292,7 @@

  • -
  • +
  • @@ -3127,7 +3303,7 @@

  • -
  • +
  • @@ -3138,7 +3314,7 @@

  • -
  • +
  • @@ -3149,7 +3325,7 @@

  • -
  • +
  • @@ -3160,7 +3336,7 @@

  • -
  • +
  • @@ -3171,7 +3347,7 @@

  • -
  • +
  • @@ -3182,7 +3358,7 @@

  • -
  • +
  • @@ -3193,7 +3369,7 @@

  • -
  • +
  • @@ -3204,7 +3380,7 @@

  • -
  • +
  • 1 @@ -3215,7 +3391,7 @@

  • -
  • +
  • @@ -3226,7 +3402,7 @@

  • -
  • +
  • @@ -3237,7 +3413,7 @@

  • -
  • +
  • @@ -3248,7 +3424,7 @@

  • -
  • +
  • 2 @@ -3259,7 +3435,7 @@

  • -
  • +
  • @@ -3270,7 +3446,7 @@

  • -
  • +
  • @@ -3281,7 +3457,7 @@

  • -
  • +
  • @@ -3292,7 +3468,7 @@

  • -
  • +
  • @@ -3303,7 +3479,7 @@

  • -
  • +
  • @@ -3314,7 +3490,7 @@

  • -
  • +
  • @@ -3325,7 +3501,7 @@

  • -
  • +
  • @@ -3336,7 +3512,7 @@

  • -
  • +
  • @@ -3347,7 +3523,7 @@

  • -
  • +
  • @@ -3358,7 +3534,7 @@

  • -
  • +
  • @@ -3369,7 +3545,7 @@

  • -
  • +
  • @@ -3380,7 +3556,7 @@

  • -
  • +
  • @@ -3391,7 +3567,7 @@

  • -
  • +
  • @@ -3402,7 +3578,7 @@

  • -
  • +
  • @@ -3413,7 +3589,7 @@

  • -
  • +
  • @@ -3424,7 +3600,7 @@

  • -
  • +
  • @@ -3435,7 +3611,7 @@

  • -
  • +
  • @@ -3446,7 +3622,7 @@

  • -
  • +
  • @@ -3457,7 +3633,7 @@

  • -
  • +
  • @@ -3468,7 +3644,7 @@

  • -
  • +
  • @@ -3479,7 +3655,7 @@

  • -
  • +
  • @@ -3490,7 +3666,7 @@

  • -
  • +
  • @@ -3501,7 +3677,7 @@

  • -
  • +
  • @@ -3512,7 +3688,7 @@

  • -
  • +
  • @@ -3523,7 +3699,7 @@

  • -
  • +
  • @@ -3534,7 +3710,7 @@

  • -
  • +
  • @@ -3545,7 +3721,7 @@

  • -
  • +
  • @@ -3556,7 +3732,7 @@

  • -
  • +
  • @@ -3567,7 +3743,7 @@

  • -
  • +
  • @@ -3578,18 +3754,29 @@

  • -
  • +
  • - session: 'Session' + session: 'Session',
  • -
  • +
  • + + + + + + primaryMember_ses: 'Primary member' +
  • +
    + +
    +
  • @@ -3600,7 +3787,29 @@

  • -
  • +
  • + + + + + + +
  • +
    + +
    +
  • + 2 + + + + + raise "Unknown field name '#{field}'" if Rails.env.development? && !field_names.keys.include?(field.to_sym) +
  • +
    + +
    +
  • @@ -3611,7 +3820,7 @@

  • -
  • +
  • 2 @@ -3622,7 +3831,7 @@

  • -
  • +
  • @@ -3633,7 +3842,7 @@

  • -
  • +
  • @@ -3644,7 +3853,7 @@

  • -
  • +
  • 1 @@ -3655,7 +3864,7 @@

  • -
  • +
  • 2 @@ -3666,7 +3875,7 @@

  • -
  • +
  • @@ -3677,7 +3886,7 @@

  • -
  • +
  • @@ -3688,7 +3897,7 @@

  • -
  • +
  • @@ -3699,7 +3908,7 @@

  • -
  • +
  • @@ -3710,7 +3919,7 @@

  • -
  • +
  • @@ -3721,7 +3930,7 @@

  • -
  • +
  • @@ -3732,7 +3941,7 @@

  • -
  • +
  • @@ -3743,7 +3952,7 @@

  • -
  • +
  • @@ -3754,7 +3963,7 @@

  • -
  • +
  • @@ -3765,7 +3974,7 @@

  • -
  • +
  • 1 @@ -3776,7 +3985,7 @@

  • -
  • +
  • @@ -3787,7 +3996,7 @@

  • -
  • +
  • @@ -3798,7 +4007,7 @@

  • -
  • +
  • @@ -3809,7 +4018,7 @@

  • -
  • +
  • @@ -3820,7 +4029,7 @@

  • -
  • +
  • @@ -3831,7 +4040,7 @@

  • -
  • +
  • 1 @@ -3842,7 +4051,7 @@

  • -
  • +
  • 2 @@ -3853,7 +4062,7 @@

  • -
  • +
  • @@ -3864,7 +4073,7 @@

  • -
  • +
  • @@ -3875,7 +4084,7 @@

  • -
  • +
  • 1 @@ -3886,7 +4095,7 @@

  • -
  • +
  • @@ -3897,7 +4106,7 @@

  • -
  • +
  • @@ -3908,8 +4117,8 @@

  • -
  • - 132 +
  • + 264 @@ -3919,7 +4128,7 @@

  • -
  • +
  • @@ -3930,7 +4139,7 @@

  • -
  • +
  • @@ -3941,7 +4150,7 @@

  • -
  • +
  • 1 @@ -3952,7 +4161,7 @@

  • -
  • +
  • @@ -3963,7 +4172,7 @@

  • -
  • +
  • @@ -3974,7 +4183,7 @@

  • -
  • +
  • @@ -3985,7 +4194,7 @@

  • -
  • +
  • @@ -3996,7 +4205,7 @@

  • -
  • +
  • @@ -4007,7 +4216,7 @@

  • -
  • +
  • 1 @@ -4018,8 +4227,8 @@

  • -
  • - 3 +
  • + 6 @@ -4029,7 +4238,7 @@

  • -
  • +
  • @@ -4040,7 +4249,7 @@

  • -
  • +
  • @@ -4059,8 +4268,8 @@

    app/helpers/date_helper.rb

    - - 100.0% + + 66.67% lines covered @@ -4069,9 +4278,9 @@

    - 5 relevant lines. - 5 lines covered and - 0 lines missed. + 9 relevant lines. + 6 lines covered and + 3 lines missed.
    @@ -4165,7 +4374,7 @@

    - data[:value].to_date.strftime(ApplicationHelper::DATE_DISPLAY_FORMAT) + data[:value].to_date.strftime(ApplicationHelper::DATE_FORMAT_WITH_DAY)

  • @@ -4187,6 +4396,94 @@

    + + +

    + +
    +
  • + 1 + + + + + def format_date_without_day(data) +
  • +
    + +
    +
  • + + + + + + return unless data +
  • +
    + +
    +
  • + + + + + + +
  • +
    + +
    +
  • + + + + + + return if data[:value].blank? +
  • +
    + +
    +
  • + + + + + + +
  • +
    + +
    +
  • + + + + + + data[:value].to_date.strftime(ApplicationHelper::DATE_FORMAT_WITHOUT_DAY) +
  • +
    + +
    +
  • + + + + + + end +
  • +
    + +
    +
  • + + + + + end
  • @@ -6526,59 +6823,6 @@

    - end - -

    - - - - - - -
    -
    -

    app/helpers/meta_helper.rb

    -

    - - 100.0% - - - lines covered -

    - - - -
    - 1 relevant lines. - 1 lines covered and - 0 lines missed. -
    - - - -
    - -
    -    
      - -
      -
    1. - 1 - - - - - module MetaHelper -
    2. -
      - -
      -
    3. - - - - - end
    4. @@ -20332,7 +20576,7 @@

      app/models/hierarchy_builder.rb

      - 81.82% + 82.35% lines covered @@ -20341,8 +20585,8 @@

      - 33 relevant lines. - 27 lines covered and + 34 relevant lines. + 28 lines covered and 6 lines missed.
      @@ -20558,7 +20802,7 @@

      - ses_data.keys.each {|a| ret[a.first] = a.last } + ses_data.keys.each { |a| ret[a.first] = a.last }

    @@ -20893,8 +21137,8 @@

    -
  • - 3 +
  • + 6 @@ -20915,13 +21159,13 @@

  • -
  • - 3 +
  • + 6 - ret = [] + return [] if ses_data.has_key?("error")
  • @@ -20932,7 +21176,7 @@

    - # select types that have 'Content Type' as their parent + @@ -20943,12 +21187,45 @@

    + ret = [] + + + +
    +
  • + + + + + + +
  • +
    + +
    +
  • + + + + + + # select types that have 'Content Type' as their parent +
  • +
    + +
    +
  • + 12 + + + + ses_data.select { |k, v| v.first.dig("fields").first.dig("field", "id") == "346696" }.keys.map do |id, name|
  • -
  • +
  • @@ -20959,7 +21236,7 @@

  • -
  • +
  • @@ -20970,7 +21247,7 @@

  • -
  • +
  • @@ -20981,8 +21258,8 @@

  • -
  • - 3 +
  • + 6 @@ -20992,7 +21269,7 @@

  • -
  • +
  • @@ -21003,7 +21280,7 @@

  • -
  • +
  • @@ -30641,8 +30918,8 @@

    app/models/search_data.rb

    - - 90.48% + + 85.9% lines covered @@ -30651,9 +30928,9 @@

    - 147 relevant lines. - 133 lines covered and - 14 lines missed. + 156 relevant lines. + 134 lines covered and + 22 lines missed.
    @@ -32754,8 +33031,8 @@

    -
  • - 5 +
  • + 8 @@ -32765,8 +33042,8 @@

  • -
  • - 5 +
  • + 8 @@ -33348,8 +33625,8 @@

  • -
  • - 15 +
  • + 21 @@ -33370,8 +33647,8 @@

  • -
  • - 14 +
  • + 20 @@ -33381,8 +33658,8 @@

  • -
  • - 14 +
  • + 20 @@ -33403,8 +33680,8 @@

  • -
  • - 14 +
  • + 20 @@ -33436,13 +33713,13 @@

  • -
  • - 18 +
  • + 24 - "topic_ses", "year", "publisher_ses").map { |k, v| { field_name: k, facets: sort_facets(v['buckets']) } } + "topic_ses", "year", "publisher_ses", "primaryMember_ses").map { |k, v| { field_name: k, facets: sort_facets(v['buckets']) } }
  • @@ -33546,8 +33823,8 @@

  • -
  • - 3 +
  • + 6 @@ -33568,8 +33845,8 @@

  • -
  • - 3 +
  • + 6 @@ -33579,8 +33856,8 @@

  • -
  • - 3 +
  • + 6 @@ -33601,8 +33878,8 @@

  • -
  • - 9 +
  • + 18 @@ -33640,13 +33917,189 @@

    + def primary_member_facets +

  • +
    + +
    +
  • + + + + + + return [] unless search +
  • +
    + +
    +
  • + + + + + + +
  • +
    + +
    +
  • + + + + + + facet_field_data = search.dig(:data, 'facets') +
  • +
    + +
    +
  • + + + + + + return [] if facet_field_data.blank? +
  • +
    + +
    +
  • + + + + + + +
  • +
    + +
    +
  • + + + + + + ret = [] +
  • +
    + +
    +
  • + + + + + + facet_field_data.dig("primaryMember_ses", "buckets").each do |bucket| +
  • +
    + +
    +
  • + + + + + + bucket.dig("unique_combined", "buckets").each do |sub_bucket| +
  • +
    + +
    +
  • + + + + + + ret << sub_bucket +
  • +
    + +
    +
  • + + + + + + end +
  • +
    + +
    +
  • + + + + + + end +
  • +
    + +
    +
  • + + + + + + +
  • +
    + +
    +
  • + + + + + + ret +
  • +
    + +
    +
  • + + + + + + end +
  • +
    + +
    +
  • + + + + + + +
  • +
    + +
    +
  • + 1 + + + + def sort_facets(facet_field)
  • -
  • - 54 +
  • + 72 @@ -33656,7 +34109,7 @@

  • -
  • +
  • @@ -33667,7 +34120,7 @@

  • -
  • +
  • @@ -33678,7 +34131,7 @@

  • -
  • +
  • 1 @@ -33689,8 +34142,8 @@

  • -
  • - 6 +
  • + 9 @@ -33700,7 +34153,7 @@

  • -
  • +
  • @@ -33711,7 +34164,7 @@

  • -
  • +
  • @@ -33722,7 +34175,7 @@

  • -
  • +
  • 1 @@ -33733,8 +34186,8 @@

  • -
  • - 8 +
  • + 11 @@ -33744,7 +34197,7 @@

  • -
  • +
  • @@ -33755,8 +34208,8 @@

  • -
  • - 6 +
  • + 9 @@ -33766,7 +34219,7 @@

  • -
  • +
  • @@ -33777,8 +34230,8 @@

  • -
  • - 6 +
  • + 9 @@ -33788,7 +34241,7 @@

  • -
  • +
  • @@ -33799,7 +34252,7 @@

  • -
  • +
  • 9 @@ -33810,7 +34263,7 @@

  • -
  • +
  • @@ -33821,7 +34274,7 @@

  • -
  • +
  • @@ -33841,7 +34294,7 @@

    app/models/ses_lookup.rb

    - 71.21% + 68.12% lines covered @@ -33850,9 +34303,9 @@

    - 66 relevant lines. + 69 relevant lines. 47 lines covered and - 19 lines missed. + 22 lines missed.
    @@ -34386,51 +34839,51 @@

    - # try to parse the response as JSON & extract terms + # extract terms

  • -
  • - +
  • + 2 - begin + terms = response.dig('terms')
  • -
  • - 2 +
  • + - parsed_response = JSON.parse(response) +
  • -
  • - 2 +
  • + - evaluated = parsed_response.dig('terms') + # collate terms from all responses
  • -
  • - +
  • + 2 - rescue JSON::ParserError + output << terms
  • @@ -34441,29 +34894,29 @@

    - # contrary to SES API documentation, errors seem to be returned as XML regardless of specified TEMPLATE + end
    -
  • +
  • - evaluated = Hash.from_xml(response) + end
  • -
  • +
  • - puts "Error: #{evaluated}" if Rails.env.development? +
  • @@ -34474,40 +34927,40 @@

    - end + # wait for all threads to have finished executing
    -
  • - +
  • + 1 - + threads.each(&:join)
  • -
  • - +
  • + 1 - # collate responses + puts "All requests completed" if Rails.env.development?
  • -
  • - 2 +
  • + - output << evaluated +
  • @@ -34518,18 +34971,18 @@

    - end + # flatten responses
    -
  • - +
  • + 1 - end + output.flatten
  • @@ -34540,7 +34993,7 @@

    - + end @@ -34551,7 +35004,7 @@

    - # wait for all threads to have finished executing + @@ -34562,56 +35015,34 @@

    - threads.each(&:join) - - - -
    -
  • - 1 - - - - - puts "All requests completed" if Rails.env.development? + def evaluated_hierarchy_response
  • -
  • +
  • - + uri = ses_browse_service_uri
  • -
  • - - - +
  • - - # flatten responses -
  • -
    - -
    -
  • - 1 - output.flatten + api_response(uri)
  • -
  • +
  • @@ -34622,7 +35053,7 @@

  • -
  • +
  • @@ -34633,51 +35064,40 @@

  • -
  • +
  • 1 - def evaluated_hierarchy_response + def test_api_response
  • -
  • +
  • - uri = ses_browse_service_uri + uri = ses_term_service_uri("346696")
  • -
  • - - - - - - response = JSON.parse(api_response(uri)) -
  • -
    - -
    -
  • +
  • - response.dig("terms") + api_response(uri)
  • -
  • +
  • @@ -34688,7 +35108,7 @@

  • -
  • +
  • @@ -34699,7 +35119,7 @@

  • -
  • +
  • 1 @@ -34710,7 +35130,7 @@

  • -
  • +
  • @@ -34721,7 +35141,7 @@

  • -
  • +
  • 2 @@ -34732,7 +35152,7 @@

  • -
  • +
  • @@ -34743,7 +35163,7 @@

  • -
  • +
  • 2 @@ -34754,7 +35174,7 @@

  • -
  • +
  • 2 @@ -34765,7 +35185,7 @@

  • -
  • +
  • @@ -34776,7 +35196,7 @@

  • -
  • +
  • @@ -34787,7 +35207,7 @@

  • -
  • +
  • @@ -34798,7 +35218,7 @@

  • -
  • +
  • @@ -34809,7 +35229,7 @@

  • -
  • +
  • @@ -34820,7 +35240,7 @@

  • -
  • +
  • @@ -34831,7 +35251,7 @@

  • -
  • +
  • 2 @@ -34842,7 +35262,7 @@

  • -
  • +
  • @@ -34853,7 +35273,7 @@

  • -
  • +
  • 2 @@ -34864,7 +35284,7 @@

  • -
  • +
  • 2 @@ -34875,7 +35295,7 @@

  • -
  • +
  • 3 @@ -34886,7 +35306,7 @@

  • -
  • +
  • @@ -34897,7 +35317,7 @@

  • -
  • +
  • @@ -34908,7 +35328,7 @@

  • -
  • +
  • 2 @@ -34919,7 +35339,7 @@

  • -
  • +
  • @@ -34930,7 +35350,7 @@

  • -
  • +
  • @@ -34941,7 +35361,7 @@

  • -
  • +
  • 1 @@ -34952,7 +35372,7 @@

  • -
  • +
  • @@ -34963,7 +35383,7 @@

  • -
  • +
  • @@ -34974,7 +35394,7 @@

  • -
  • +
  • @@ -34985,7 +35405,7 @@

  • -
  • +
  • @@ -34996,7 +35416,7 @@

  • -
  • +
  • @@ -35007,7 +35427,7 @@

  • -
  • +
  • @@ -35018,7 +35438,7 @@

  • -
  • +
  • @@ -35029,7 +35449,7 @@

  • -
  • +
  • @@ -35040,7 +35460,7 @@

  • -
  • +
  • @@ -35051,7 +35471,7 @@

  • -
  • +
  • @@ -35062,7 +35482,7 @@

  • -
  • +
  • @@ -35073,18 +35493,18 @@

  • -
  • +
  • - return responses.first if responses.first&.has_key?(:error) + return responses if responses.has_key?("error")
  • -
  • +
  • @@ -35095,29 +35515,40 @@

  • -
  • +
  • - unless responses.compact.blank? + terms = responses.dig('terms')
  • -
  • +
  • - responses.each do |response| + unless terms.compact.blank?
  • -
  • +
  • + + + + + + terms.each do |term| +
  • +
    + +
    +
  • @@ -35128,40 +35559,40 @@

  • -
  • +
  • - new_key << response.dig('term', 'id')&.to_i + new_key << term.dig('term', 'id')&.to_i
  • -
  • +
  • - new_key << response.dig('term', 'name') + new_key << term.dig('term', 'name')
  • -
  • +
  • - ret[new_key] = response.dig('term', 'hierarchy') + ret[new_key] = term.dig('term', 'hierarchy')
  • -
  • +
  • @@ -35172,7 +35603,7 @@

  • -
  • +
  • @@ -35183,7 +35614,7 @@

  • -
  • +
  • @@ -35194,7 +35625,7 @@

  • -
  • +
  • @@ -35205,7 +35636,7 @@

  • -
  • +
  • @@ -35216,7 +35647,7 @@

  • -
  • +
  • @@ -35227,7 +35658,7 @@

  • -
  • +
  • 1 @@ -35238,7 +35669,7 @@

  • -
  • +
  • 4 @@ -35249,7 +35680,7 @@

  • -
  • +
  • @@ -35260,7 +35691,7 @@

  • -
  • +
  • @@ -35271,7 +35702,7 @@

  • -
  • +
  • 1 @@ -35282,7 +35713,7 @@

  • -
  • +
  • @@ -35293,7 +35724,7 @@

  • -
  • +
  • @@ -35304,7 +35735,7 @@

  • -
  • +
  • @@ -35315,7 +35746,7 @@

  • -
  • +
  • 1 @@ -35326,7 +35757,7 @@

  • -
  • +
  • @@ -35337,7 +35768,7 @@

  • -
  • +
  • 1 @@ -35348,7 +35779,7 @@

  • -
  • +
  • 2 @@ -35359,7 +35790,7 @@

  • -
  • +
  • @@ -35370,7 +35801,7 @@

  • -
  • +
  • @@ -35381,7 +35812,7 @@

  • -
  • +
  • 1 @@ -35392,7 +35823,7 @@

  • -
  • +
  • @@ -35402,6 +35833,28 @@

  • +
    +
  • + + + + + + +
  • +
    + +
    +
  • + + + + + + raw_response = api_get_request(uri) +
  • +
    +
  • @@ -35414,24 +35867,24 @@

  • -
  • +
  • - api_get_request(uri) + begin
  • -
  • +
  • - end + JSON.parse(raw_response)
  • @@ -35442,6 +35895,72 @@

    + rescue JSON::ParserError + + + +
    +
  • + + + + + + # contrary to SES API documentation, errors seem to be returned as XML regardless of specified TEMPLATE +
  • +
    + +
    +
  • + + + + + + evaluated_as_xml = Hash.from_xml(raw_response) +
  • +
    + +
    +
  • + + + + + + puts "Error: #{evaluated_as_xml}" if Rails.env.development? +
  • +
    + +
    +
  • + + + + + + end +
  • +
    + +
    +
  • + + + + + + end +
  • +
    + +
    +
  • + + + + + end
  • @@ -36286,7 +36805,7 @@

    app/models/solr_search.rb

    - 37.69% + 37.4% lines covered @@ -36295,9 +36814,9 @@

    - 130 relevant lines. + 131 relevant lines. 49 lines covered and - 81 lines missed. + 82 lines missed.
    @@ -39053,7 +39572,7 @@

    - # "start": "1500-01-01T00:00:00Z", + "start": "1500-01-01T00:00:00Z", @@ -39152,7 +39671,7 @@

    - # "start": "1500-01-01T00:00:00Z", + "start": "1500-01-01T00:00:00Z", @@ -39328,7 +39847,7 @@

    - ret.to_json + ret['primaryMember_ses'] = { @@ -39339,7 +39858,7 @@

    - end + "type": "terms", @@ -39350,40 +39869,40 @@

    - + "field": "askingMember_ses",
    -
  • - 1 +
  • + - def facet_type(field_name) + "limit": 80,
  • -
  • +
  • - arr = [] + "facet": {
  • -
  • +
  • - return "terms" unless arr.include?(field_name) + "unique_combined": {
  • @@ -39394,18 +39913,18 @@

    - + "type": "terms",
    -
  • +
  • - " " # replacement type + "field": "leadMember_ses",
  • @@ -39416,7 +39935,7 @@

    - end + "limit": -1, @@ -39427,18 +39946,18 @@

    - + "facet": {
    -
  • - 1 +
  • + - def facet_limit(field_name) + "unique_count": "unique(askingMember_ses)"
  • @@ -39449,18 +39968,18 @@

    - # limit to 80 except for + }
    -
  • +
  • - facet_names = ["type_sesrollup"] + }
  • @@ -39471,18 +39990,18 @@

    - + }
    -
  • +
  • - return 80 unless facet_names.include?(field_name) + }
  • @@ -39504,7 +40023,7 @@

    - -1 + ret.to_json @@ -39537,7 +40056,7 @@

    - def facet_mincount(field_name) + def facet_type(field_name) @@ -39559,7 +40078,7 @@

    - return 1 unless arr.include?(field_name) + return "terms" unless arr.include?(field_name) @@ -39581,7 +40100,7 @@

    - 0 # replacement mincount + " " # replacement type @@ -39614,7 +40133,7 @@

    - def self.sessions + def facet_limit(field_name) @@ -39625,13 +40144,189 @@

    + # limit to 80 except for + + + +
    +
  • + + + + + + facet_names = ["type_sesrollup"] +
  • +
    + +
    +
  • + + + + + + +
  • +
    + +
    +
  • + + + + + + return 80 unless facet_names.include?(field_name) +
  • +
    + +
    +
  • + + + + + + +
  • +
    + +
    +
  • + + + + + + -1 +
  • +
    + +
    +
  • + + + + + + end +
  • +
    + +
    +
  • + + + + + + +
  • +
    + +
    +
  • + 1 + + + + + def facet_mincount(field_name) +
  • +
    + +
    +
  • + + + + + + arr = [] +
  • +
    + +
    +
  • + + + + + + return 1 unless arr.include?(field_name) +
  • +
    + +
    +
  • + + + + + + +
  • +
    + +
    +
  • + + + + + + 0 # replacement mincount +
  • +
    + +
    +
  • + + + + + + end +
  • +
    + +
    +
  • + + + + + + +
  • +
    + +
    +
  • + 1 + + + + + def self.sessions +
  • +
    + +
    +
  • + + + + + [
  • -
  • - 9 +
  • + 18 @@ -39641,7 +40336,7 @@

  • -
  • +
  • @@ -39652,7 +40347,7 @@

  • -
  • +
  • @@ -39663,7 +40358,7 @@

  • -
  • +
  • @@ -39674,7 +40369,7 @@

  • -
  • +
  • @@ -39685,7 +40380,7 @@

  • -
  • +
  • @@ -39696,7 +40391,7 @@

  • -
  • +
  • @@ -39707,7 +40402,7 @@

  • -
  • +
  • @@ -39718,7 +40413,7 @@

  • -
  • +
  • @@ -39729,7 +40424,7 @@

  • -
  • +
  • @@ -39740,7 +40435,7 @@

  • -
  • +
  • @@ -39751,7 +40446,7 @@

  • -
  • +
  • @@ -39762,7 +40457,7 @@

  • -
  • +
  • @@ -39773,7 +40468,7 @@

  • -
  • +
  • @@ -39784,7 +40479,7 @@

  • -
  • +
  • @@ -39795,7 +40490,7 @@

  • -
  • +
  • @@ -39806,7 +40501,7 @@

  • -
  • +
  • @@ -39817,7 +40512,7 @@

  • -
  • +
  • @@ -39828,7 +40523,7 @@

  • -
  • +
  • @@ -39839,7 +40534,7 @@

  • -
  • +
  • @@ -39850,7 +40545,7 @@

  • -
  • +
  • @@ -39861,7 +40556,7 @@

  • -
  • +
  • @@ -39872,7 +40567,7 @@

  • -
  • +
  • @@ -39883,7 +40578,7 @@

  • -
  • +
  • @@ -39894,7 +40589,7 @@

  • -
  • +
  • @@ -39905,7 +40600,7 @@

  • -
  • +
  • @@ -39916,7 +40611,7 @@

  • -
  • +
  • @@ -39927,7 +40622,7 @@

  • -
  • +
  • @@ -39938,7 +40633,7 @@

  • -
  • +
  • @@ -39949,7 +40644,7 @@

  • -
  • +
  • @@ -39960,7 +40655,7 @@

  • -
  • +
  • @@ -39971,7 +40666,7 @@

  • -
  • +
  • @@ -39982,7 +40677,7 @@

  • -
  • +
  • @@ -39993,7 +40688,7 @@

  • -
  • +
  • @@ -40004,7 +40699,7 @@

  • -
  • +
  • @@ -40015,7 +40710,7 @@

  • -
  • +
  • @@ -40026,7 +40721,7 @@

  • -
  • +
  • @@ -40037,7 +40732,7 @@

  • -
  • +
  • @@ -40048,7 +40743,7 @@

  • -
  • +
  • @@ -40059,7 +40754,7 @@

  • -
  • +
  • @@ -40070,7 +40765,7 @@

  • -
  • +
  • @@ -40081,7 +40776,7 @@

  • -
  • +
  • @@ -40092,7 +40787,7 @@

  • -
  • +
  • @@ -40103,7 +40798,7 @@

  • -
  • +
  • @@ -40114,7 +40809,7 @@

  • -
  • +
  • @@ -40125,7 +40820,7 @@

  • -
  • +
  • @@ -40136,7 +40831,7 @@

  • -
  • +
  • @@ -40147,7 +40842,7 @@

  • -
  • +
  • 1 @@ -40158,7 +40853,7 @@

  • -
  • +
  • @@ -40169,7 +40864,7 @@

  • -
  • +
  • 1 @@ -40180,7 +40875,7 @@

  • -
  • +
  • @@ -40191,7 +40886,7 @@

  • -
  • +
  • @@ -40202,7 +40897,7 @@

  • -
  • +
  • @@ -40213,7 +40908,7 @@

  • -
  • +
  • @@ -40224,7 +40919,7 @@

  • -
  • +
  • @@ -40235,7 +40930,7 @@

  • -
  • +
  • @@ -40246,7 +40941,7 @@

  • -
  • +
  • @@ -40257,7 +40952,7 @@

  • -
  • +
  • @@ -40268,7 +40963,7 @@

  • -
  • +
  • @@ -40279,7 +40974,7 @@

  • -
  • +
  • @@ -40290,7 +40985,7 @@

  • -
  • +
  • diff --git a/spec/models/ses_lookup_spec.rb b/spec/models/ses_lookup_spec.rb index 87384b8f..8846d481 100644 --- a/spec/models/ses_lookup_spec.rb +++ b/spec/models/ses_lookup_spec.rb @@ -91,15 +91,15 @@ describe 'evaluated_responses' do let!(:ses_api_call) { SesLookup.new([{ value: 92347, field_name: 'type_ses' }, { value: 92350, field_name: 'type_ses' }, { value: 92352, field_name: 'type_ses' }]) } - let!(:deserialised_response) { { "1" => "a", "2" => "b" } } + let!(:deserialised_response) { { "terms" => { "1" => "a", "2" => "b" } } } let!(:serialised_response) { "{\"terms\":{\"1\":\"a\",\"2\":\"b\"}}" } it 'parses the response' do # artificially reduce the threshold for grouping allow(ses_api_call).to receive(:group_size).and_return(2) - allow(ses_api_call).to receive(:api_response).and_return(serialised_response) - expect(ses_api_call.send(:evaluated_responses)).to eq([deserialised_response, deserialised_response]) + allow(ses_api_call).to receive(:api_response).and_return(deserialised_response) + expect(ses_api_call.send(:evaluated_responses)).to eq([deserialised_response['terms'], deserialised_response['terms']]) end end end