From 65a6c0f82b0ec601aff6f09e672175b00f73d0af Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Thu, 7 May 2020 10:43:00 +0200 Subject: [PATCH 1/2] clean up event aggregations and facets. #503 --- app/controllers/concerns/facetable.rb | 157 +++++------------------ app/controllers/events_controller.rb | 17 +-- app/controllers/old_events_controller.rb | 6 +- app/models/concerns/indexable.rb | 26 +--- app/models/doi.rb | 2 - app/models/event.rb | 66 ++++++++-- 6 files changed, 92 insertions(+), 182 deletions(-) diff --git a/app/controllers/concerns/facetable.rb b/app/controllers/concerns/facetable.rb index bffc3b053..167e7e46c 100644 --- a/app/controllers/concerns/facetable.rb +++ b/app/controllers/concerns/facetable.rb @@ -121,18 +121,6 @@ def facet_by_resource_type(arr) end end - def facet_by_year_month(arr) - arr.map do |hsh| - month = hsh["key_as_string"][5..6].to_i - title = I18n.t("date.month_names")[month] + " " + hsh["key_as_string"][0..3] - - { "id" => hsh["key_as_string"][0..6], - "title" => title, - "count" => hsh["doc_count"], - "sum" => hsh.dig("total_by_year_month", "value") } - end - end - def facet_by_source(arr) arr.map do |hsh| { "id" => hsh["key"], @@ -141,170 +129,83 @@ def facet_by_source(arr) end end - def facet_citations_by_year(hash) - arr = hash.dig('years', 'buckets').map do |h| - year = h['key'] - title = h['key'].to_i.to_s - - { - 'id' => year, - 'title' => title, - 'sum' => h.dig('total_by_year', 'value') } - end - { "count" => hash.dig("sum_distribution", "value"), - "years" => arr } - end - - def facet_citations_by_year_v1(hash) - arr = hash.dig('years', 'buckets').map do |h| - year = h["key_as_string"][0..3].to_i - title = h["key_as_string"][0..3] - - { - 'id' => year, - 'title' => title, - 'sum' => h.dig('total_by_year', 'value') } - end - { "count" => hash.dig("sum_distribution", "value"), - "years" => arr } - end - - def facet_counts_by_year_month(hash) - arr = hash.dig('year_months', 'buckets').map do |h| - month = h["key_as_string"][5..6].to_i - title = I18n.t("date.month_names")[month] + " " + h["key_as_string"][0..3] - - { - "id" => h["key_as_string"][0..6], - 'title' => title, - 'sum' => h.dig('total_by_year_month', 'value') } - end - { "count" => hash.dig("sum_distribution", "value"), - "yearMonths" => arr } - end - def facet_by_relation_type(arr) arr.map do |hsh| - arr = hsh.dig("year_months", "buckets").map do |h| - month = h["key_as_string"][5..6].to_i - title = I18n.t("date.month_names")[month] + " " + h["key_as_string"][0..3] - + year_month_arr = hsh.dig("year_month", "buckets").map do |h| { - "id" => h["key_as_string"][0..6], - "title" => title, - "sum" => h.dig("total_by_year_month", "value") } + "id" => h["key_as_string"], + "title" => h["key_as_string"], + "sum" => h["doc_count"] } end { "id" => hsh["key"], "title" => hsh["key"], - "count" => hsh.dig("sum_distribution", "value"), - "yearMonths" => arr } + "count" => hsh["doc_count"], + "yearMonths" => year_month_arr } end end def facet_by_relation_type_v1(arr) arr.map do |hsh| - arr = hsh.dig("year_months", "buckets").map do |h| - month = h["key_as_string"][5..6].to_i - title = I18n.t("date.month_names")[month] + " " + h["key_as_string"][0..3] - + year_month_arr = hsh.dig("year_month", "buckets").map do |h| { - "id" => h["key_as_string"][0..6], - "title" => title, - "sum" => h.dig("total_by_year_month", "value") } + "id" => h["key_as_string"], + "title" => h["key_as_string"], + "sum" => h["doc_count"] } end { "id" => hsh["key"], "title" => hsh["key"], - "count" => hsh.dig("sum_distribution", "value"), - "year-months" => arr } + "count" => hsh["doc_count"], + "year-months" => year_month_arr } end end def facet_by_citation_type(arr) arr.map do |hsh| - arr = hsh.dig("year_months", "buckets").map do |h| - month = h["key_as_string"][5..6].to_i - title = I18n.t("date.month_names")[month] + " " + h["key_as_string"][0..3] - + year_month_arr = hsh.dig("year_month", "buckets").map do |h| { - "id" => h["key_as_string"][0..6], - "title" => title, - "sum" => h.dig("total_by_year_month", "value") } + "id" => h["key_as_string"], + "title" => h["key_as_string"], + "sum" => h["doc_count"] } end { "id" => hsh["key"], "title" => hsh["key"], "count" => hsh["doc_count"], - "year-months" => arr } + "yearMonths" => year_month_arr } end end - def facet_by_pairings(arr) + def facet_by_citation_type_v1(arr) arr.map do |hsh| - arr = hsh.dig("recipient", "buckets").map do |h| - title = h["key"] + year_month_arr = hsh.dig("year_month", "buckets").map do |h| { - "id" => h["key"], - "title" => title, - "sum" => h.dig("total", "value") } + "id" => h["key_as_string"], + "title" => h["key_as_string"], + "sum" => h["doc_count"] } end - arr.reject! {|h| h["id"] == hsh["key"]} + { "id" => hsh["key"], "title" => hsh["key"], "count" => hsh["doc_count"], - "registrants" => arr } + "year-months" => year_month_arr } end end def facet_by_registrants(arr) arr.map do |hsh| - arr = hsh.dig("year", "buckets").map do |h| - title = h["key_as_string"][0..3] - + year_arr = hsh.dig("year", "buckets").map do |h| { - "id" => h["key_as_string"][0..3], - "title" => title, - "sum" => h.dig("total_by_year", "value") } + "id" => h["key_as_string"], + "title" => h["key_as_string"], + "sum" => h["doc_count"] } end { "id" => hsh["key"], "title" => hsh["key"], "count" => hsh["doc_count"], - "years" => arr } - end - end - - def facet_by_metric_type(arr) - arr.map do |hsh| - { "id" => hsh["key"], - "title" => hsh["key"].gsub(/-/, ' ').titleize, - "count" => hsh["doc_count"] } - end - end - - def facet_by_dois(arr) - arr.map do |hsh| - arr = hsh.dig("relation_types", "buckets").map do |h| - title = h["key"] - { - "id" => h["key"], - "title" => title, - "sum" => h.dig("total_by_type", "value") } - end - arr.reject! {|h| h["id"] == hsh["key"]} - { "id" => hsh["key"], - "title" => hsh["key"], - "count" => hsh["doc_count"], - "relationTypes" => arr } - end - end - - def facet_citations_by_dois(arr) - arr.map do |hsh| - { "id" => hsh["key"], - "title" => hsh["key"], - "count" => hsh.dig("total", "value")} + "years" => year_arr } end end diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb index 48f54bef5..6666e40a5 100644 --- a/app/controllers/events_controller.rb +++ b/app/controllers/events_controller.rb @@ -139,16 +139,12 @@ def index render json: EventSerializer.new(results, options).serialized_json, status: :ok else - aggregations = params.fetch(:aggregations, "") || "" - - sources = total.positive? && aggregations.blank? || aggregations.include?("query_aggregations") ? facet_by_source(response.response.aggregations.sources.buckets) : nil - prefixes = total.positive? && aggregations.blank? || aggregations.include?("query_aggregations") ? facet_by_source(response.response.aggregations.prefixes.buckets) : nil - citation_types = total.positive? && aggregations.blank? || aggregations.include?("query_aggregations") ? facet_by_citation_type(response.response.aggregations.citation_types.buckets) : nil - relation_types = total.positive? && aggregations.blank? || aggregations.include?("query_aggregations") ? facet_by_relation_type(response.response.aggregations.relation_types.buckets) : nil - registrants = total.positive? && aggregations.blank? || aggregations.include?("query_aggregations") ? facet_by_registrants(response.response.aggregations.registrants.buckets) : nil - pairings = total.positive? && aggregations.blank? || aggregations.include?("query_aggregations") ? facet_by_pairings(response.response.aggregations.pairings.buckets) : nil - states = total.positive? && aggregations.include?("state_aggregations") ? facet_by_source(response.response.aggregations.states.buckets) : nil - + sources = total.positive? ? facet_by_source(response.response.aggregations.sources.buckets) : nil + prefixes = total.positive? ? facet_by_source(response.response.aggregations.prefixes.buckets) : nil + citation_types = total.positive? ? facet_by_citation_type(response.response.aggregations.citation_types.buckets) : nil + relation_types = total.positive? ? facet_by_relation_type(response.response.aggregations.relation_types.buckets) : nil + registrants = total.positive? ? facet_by_registrants(response.response.aggregations.registrants.buckets) : nil + results = response.results options = {} @@ -160,7 +156,6 @@ def index prefixes: prefixes, "citationTypes" => citation_types, "relationTypes" => relation_types, - pairings: pairings, registrants: registrants, "states": states, }.compact diff --git a/app/controllers/old_events_controller.rb b/app/controllers/old_events_controller.rb index 79a68113b..26c46b442 100644 --- a/app/controllers/old_events_controller.rb +++ b/app/controllers/old_events_controller.rb @@ -132,10 +132,9 @@ def index else sources = total > 0 ? facet_by_source(response.aggregations.sources.buckets) : nil prefixes = total > 0 ? facet_by_source(response.aggregations.prefixes.buckets) : nil - citation_types = total > 0 ? facet_by_citation_type(response.aggregations.citation_types.buckets) : nil + citation_types = total > 0 ? facet_by_citation_type_v1(response.aggregations.citation_types.buckets) : nil relation_types = total > 0 ? facet_by_relation_type_v1(response.aggregations.relation_types.buckets) : nil - registrants = total > 0 && params[:extra] ? facet_by_registrants(response.aggregations.registrants.buckets) : nil - pairings = total > 0 && params[:extra] ? facet_by_pairings(response.aggregations.pairings.buckets) : nil + registrants = total > 0 ? facet_by_registrants(response.aggregations.registrants.buckets) : nil results = response.results @@ -148,7 +147,6 @@ def index prefixes: prefixes, "citation-types" => citation_types, "relation-types" => relation_types, - pairings: pairings, registrants: registrants }.compact diff --git a/app/models/concerns/indexable.rb b/app/models/concerns/indexable.rb index 1cc52cc39..bc3f92451 100644 --- a/app/models/concerns/indexable.rb +++ b/app/models/concerns/indexable.rb @@ -124,17 +124,6 @@ def find_by_id_list(ids, options={}) }) end - def get_aggregations_hash(options={}) - aggregations = options[:aggregations] || "" - return send(:query_aggregations) if aggregations.blank? - aggs = {} - aggregations.split(",").each do |agg| - agg = :query_aggregations if agg.blank? || !respond_to?(agg) - aggs.merge! send(agg) - end - aggs - end - def query(query, options={}) # support scroll api # map function is small performance hit @@ -168,7 +157,7 @@ def query(query, options={}) elsif options[:totals_agg] == "prefix" aggregations = prefix_aggregations else - aggregations = get_aggregations_hash(options) + aggregations = query_aggregations end options[:page] ||= {} @@ -346,16 +335,6 @@ def query(query, options={}) } end - # Collap results list by unique citations - unique = options[:unique].blank? ? nil : { - field: "citation_id", - inner_hits: { - name: "first_unique_event", - size: 1 - }, - "max_concurrent_group_searches": 1 - } - # three options for going through results are scroll, cursor and pagination # the default is pagination # scroll is triggered by the page[scroll] query parameter @@ -371,7 +350,6 @@ def query(query, options={}) size: options.dig(:page, :size), sort: sort, query: es_query, - collapse: unique, aggregations: aggregations, track_total_hits: true }.compact) @@ -386,7 +364,6 @@ def query(query, options={}) search_after: search_after, sort: sort, query: es_query, - collapse: unique, aggregations: aggregations, track_total_hits: true }.compact) @@ -396,7 +373,6 @@ def query(query, options={}) from: from, sort: sort, query: es_query, - collapse: unique, aggregations: aggregations, track_total_hits: true }.compact) diff --git a/app/models/doi.rb b/app/models/doi.rb index 2320d14b2..50056f5c1 100644 --- a/app/models/doi.rb +++ b/app/models/doi.rb @@ -711,8 +711,6 @@ def self.query(query, options={}) aggregations = client_export_aggregations elsif options[:totals_agg] == "prefix" aggregations = prefix_aggregations - else - aggregations = get_aggregations_hash(options) end # Cursor nav use the search after, this should always be an array of values that match the sort. diff --git a/app/models/event.rb b/app/models/event.rb index c2d507504..565f09f00 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -213,20 +213,62 @@ def self.query_fields def self.query_aggregations { - sources: { terms: { field: "source_id", size: 50, min_doc_count: 1 } }, - prefixes: { terms: { field: "prefix", size: 50, min_doc_count: 1 } }, - registrants: { terms: { field: "registrant_id", size: 50, min_doc_count: 1 }, aggs: { year: { date_histogram: { field: "occurred_at", interval: "year", min_doc_count: 1 }, aggs: { "total_by_year" => { sum: { field: "total" } } } } } }, - pairings: { terms: { field: "registrant_id", size: 50, min_doc_count: 1 }, aggs: { recipient: { terms: { field: "registrant_id", size: 50, min_doc_count: 1 }, aggs: { "total" => { sum: { field: "total" } } } } } }, - citation_types: { terms: { field: "citation_type", size: 50, min_doc_count: 1 }, aggs: { year_months: { date_histogram: { field: "occurred_at", interval: "month", min_doc_count: 1 }, aggs: { "total_by_year_month" => { sum: { field: "total" } } } } } }, - relation_types: { terms: { field: "relation_type_id", size: 50, min_doc_count: 1 }, aggs: { year_months: { date_histogram: { field: "occurred_at", interval: "month", min_doc_count: 1 }, aggs: { "total_by_year_month" => { sum: { field: "total" } } } } } }, - dois: { terms: { field: "obj_id", size: 50, min_doc_count: 1 }, aggs: { relation_types: { terms: { field: "relation_type_id", size: 50, min_doc_count: 1 }, aggs: { "total_by_type" => { sum: { field: "total" } } } } } }, + sources: { terms: { field: "source_id", size: 10, min_doc_count: 1 } }, + prefixes: { terms: { field: "prefix", size: 10, min_doc_count: 1 } }, + registrants: { + terms: { + field: "registrant_id", size: 10, min_doc_count: 1 + }, + aggs: { + year: { + date_histogram: { + field: 'occurred_at', interval: 'year', format: 'year', order: { _key: "desc" }, min_doc_count: 1 + }, + aggs: { + bucket_truncate: { + bucket_sort: { size: 10 } + } + } + } + } + }, + citation_types: { + terms: { + field: "citation_type", size: 10, min_doc_count: 1 + }, + aggs: { + year_month: { + date_histogram: { + field: 'occurred_at', interval: 'month', format: 'yyyy-MM', order: { _key: "desc" }, min_doc_count: 1 + }, + aggs: { + bucket_truncate: { + bucket_sort: { size: 10 } + } + } + } + } + }, + relation_types: { + terms: { + field: "relation_type_id", size: 10, min_doc_count: 1 + }, + aggs: { + year_month: { + date_histogram: { + field: 'occurred_at', interval: 'month', format: 'yyyy-MM', order: { _key: "desc" }, min_doc_count: 1 + }, + aggs: { + bucket_truncate: { + bucket_sort: { size: 10 } + } + } + } + } + }, } end - def self.state_aggregations - { states: { terms: { field: "state_event", size: 50, min_doc_count: 1 } }} - end - # return results for one or more ids def self.find_by_id(ids, options = {}) ids = ids.split(",") if ids.is_a?(String) @@ -593,7 +635,7 @@ def subtype def citation_type return nil if subj["@type"].blank? || subj["@type"] == "CreativeWork" || obj["@type"].blank? || obj["@type"] == "CreativeWork" - [subj["@type"], obj["@type"]].compact.sort.join("-") + [subj["@type"], obj["@type"]].compact.sort.join("-") end def doi_from_url(url) From 64f0eea1d7d4ce61b5c2772cdfbd2ed43da802a5 Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Thu, 7 May 2020 13:28:00 +0200 Subject: [PATCH 2/2] small tweaks --- app/controllers/clients_controller.rb | 2 +- app/controllers/events_controller.rb | 1 - app/controllers/export_controller.rb | 2 +- app/controllers/old_events_controller.rb | 12 ---------- app/controllers/repositories_controller.rb | 14 +++++------ app/models/doi.rb | 2 ++ app/serializers/old_event_serializer.rb | 3 --- app/serializers/old_object_serializer.rb | 11 --------- spec/concerns/indexable_spec.rb | 28 ---------------------- spec/requests/exports_spec.rb | 2 +- 10 files changed, 12 insertions(+), 65 deletions(-) delete mode 100644 app/serializers/old_object_serializer.rb diff --git a/app/controllers/clients_controller.rb b/app/controllers/clients_controller.rb index f3192f52c..4d2803c06 100644 --- a/app/controllers/clients_controller.rb +++ b/app/controllers/clients_controller.rb @@ -156,7 +156,7 @@ def totals page = { size: 0, number: 1 } state = current_user.present? && current_user.is_admin_or_staff? && params[:state].present? ? params[:state] : "registered,findable" response = Doi.query(nil, provider_id: params[:provider_id], state: state, page: page, totals_agg: "client") - registrant = response.results.total.positive? ? clients_totals(response.response.aggregations.clients_totals.buckets) : [] + registrant = response.results.total.positive? ? clients_totals(response.aggregations.clients_totals.buckets) : [] render json: registrant, status: :ok end diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb index 6666e40a5..211e54728 100644 --- a/app/controllers/events_controller.rb +++ b/app/controllers/events_controller.rb @@ -157,7 +157,6 @@ def index "citationTypes" => citation_types, "relationTypes" => relation_types, registrants: registrants, - "states": states, }.compact options[:links] = { diff --git a/app/controllers/export_controller.rb b/app/controllers/export_controller.rb index 7fa434178..ca503b72e 100644 --- a/app/controllers/export_controller.rb +++ b/app/controllers/export_controller.rb @@ -236,7 +236,7 @@ def repositories response = Doi.query(nil, state: "registered,findable", page: { size: 0, number: 1 }, totals_agg: "client_export") client_totals = {} - totals_buckets = response.response.aggregations.clients_totals.buckets + totals_buckets = response.aggregations.clients_totals.buckets totals_buckets.each do |totals| client_totals[totals["key"]] = { "count" => totals["doc_count"], diff --git a/app/controllers/old_events_controller.rb b/app/controllers/old_events_controller.rb index 26c46b442..d77fbf311 100644 --- a/app/controllers/old_events_controller.rb +++ b/app/controllers/old_events_controller.rb @@ -7,7 +7,6 @@ class OldEventsController < ApplicationController prepend_before_action :authenticate_user!, except: [:index, :show] before_action :detect_crawler before_action :load_event, only: [:show, :destroy] - before_action :set_include, only: [:index, :show, :create, :update] authorize_resource only: [:destroy] def create @@ -56,7 +55,6 @@ def update def show options = {} - options[:include] = @include options[:is_collection] = false render json: OldEventSerializer.new(@event, options).serialized_json, status: :ok @@ -171,7 +169,6 @@ def index "page[number]" => page[:cursor].nil? && page[:number].present? ? page[:number] + 1 : nil, "page[size]" => page[:size] }.compact.to_query }.compact - options[:include] = @include options[:is_collection] = true render json: OldEventSerializer.new(results, options).serialized_json, status: :ok @@ -195,15 +192,6 @@ def load_event fail ActiveRecord::RecordNotFound unless @event.present? end - def set_include - if params[:include].present? - @include = params[:include].split(",").map { |i| i.downcase.underscore.to_sym } - @include = @include & [:subj, :obj] - else - @include = [] - end - end - private def safe_params diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index be265ef6c..acd15141d 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -44,12 +44,12 @@ def index begin total = response.results.total total_pages = page[:size] > 0 ? (total.to_f / page[:size]).ceil : 0 - years = total > 0 ? facet_by_year(response.response.aggregations.years.buckets) : nil - providers = total > 0 ? facet_by_combined_key(response.response.aggregations.providers.buckets) : nil - software = total > 0 ? facet_by_software(response.response.aggregations.software.buckets) : nil - certificates = total > 0 ? facet_by_key(response.response.aggregations.certificates.buckets) : nil - client_types = total > 0 ? facet_by_key(response.response.aggregations.client_types.buckets) : nil - repository_types = total > 0 ? facet_by_key(response.response.aggregations.repository_types.buckets) : nil + years = total > 0 ? facet_by_year(response.aggregations.years.buckets) : nil + providers = total > 0 ? facet_by_combined_key(response.aggregations.providers.buckets) : nil + software = total > 0 ? facet_by_software(response.aggregations.software.buckets) : nil + certificates = total > 0 ? facet_by_key(response.aggregations.certificates.buckets) : nil + client_types = total > 0 ? facet_by_key(response.aggregations.client_types.buckets) : nil + repository_types = total > 0 ? facet_by_key(response.aggregations.repository_types.buckets) : nil respond_to do |format| format.json do @@ -194,7 +194,7 @@ def totals state = current_user.present? && current_user.is_admin_or_staff? && params[:state].present? ? params[:state] : "registered,findable" response = Doi.query(nil, provider_id: params[:provider_id], state: state, page: page, totals_agg: "client") - registrant = response.results.total.positive? ? clients_totals(response.response.aggregations.clients_totals.buckets) : [] + registrant = response.results.total.positive? ? clients_totals(response.aggregations.clients_totals.buckets) : [] render json: registrant, status: :ok end diff --git a/app/models/doi.rb b/app/models/doi.rb index 50056f5c1..5c6b88d8e 100644 --- a/app/models/doi.rb +++ b/app/models/doi.rb @@ -711,6 +711,8 @@ def self.query(query, options={}) aggregations = client_export_aggregations elsif options[:totals_agg] == "prefix" aggregations = prefix_aggregations + else + aggregations = query_aggregations end # Cursor nav use the search after, this should always be an array of values that match the sort. diff --git a/app/serializers/old_event_serializer.rb b/app/serializers/old_event_serializer.rb index 8e996d544..8c172f229 100644 --- a/app/serializers/old_event_serializer.rb +++ b/app/serializers/old_event_serializer.rb @@ -5,9 +5,6 @@ class OldEventSerializer set_id :uuid attributes :subj_id, :obj_id, :source_id, :relation_type_id, :total, :message_action, :source_token, :license, :occurred_at, :timestamp - - belongs_to :subj, serializer: OldObjectSerializer, record_type: :objects - belongs_to :obj, serializer: OldObjectSerializer, record_type: :objects attribute :timestamp, &:updated_at end diff --git a/app/serializers/old_object_serializer.rb b/app/serializers/old_object_serializer.rb deleted file mode 100644 index e8e78da73..000000000 --- a/app/serializers/old_object_serializer.rb +++ /dev/null @@ -1,11 +0,0 @@ -class OldObjectSerializer - include FastJsonapi::ObjectSerializer - set_key_transform :dash - set_type :objects - - attributes :subtype, :name, :author, :periodical, :volume_number, :issue_number, :pagination, :publisher, :issn, :version, :date_published - - attribute :subtype do |object| - object["@type"] - end -end diff --git a/spec/concerns/indexable_spec.rb b/spec/concerns/indexable_spec.rb index f9fc5a48c..4f118f480 100644 --- a/spec/concerns/indexable_spec.rb +++ b/spec/concerns/indexable_spec.rb @@ -207,33 +207,5 @@ expect(subject.ror_from_url(ror_id)).to be_nil end end - - context "aggregations" do - it 'returns query_aggregation when filters aggregation with empty' do - aggregations = Doi.get_aggregations_hash({aggregations:""}) - expect(aggregations[:resource_types]).not_to be_nil - expect(aggregations[:states]).not_to be_nil - expect(aggregations[:created]).not_to be_nil - expect(aggregations[:schema_versions]).not_to be_nil - end - - it 'returns multiple aggregations when filters aggregations with multiple' do - aggregations = Doi.get_aggregations_hash({aggregations:""}) - expect(aggregations[:resource_types]).not_to be_nil - expect(aggregations[:states]).not_to be_nil - expect(aggregations[:created]).not_to be_nil - expect(aggregations[:schema_versions]).not_to be_nil - end - end - end - - context "when event" do - let!(:event) { create(:event) } - let!(:events) { create_list(:event, 3) } - - before do - Event.import - sleep 2 - end end end diff --git a/spec/requests/exports_spec.rb b/spec/requests/exports_spec.rb index b6327dace..442c8d542 100644 --- a/spec/requests/exports_spec.rb +++ b/spec/requests/exports_spec.rb @@ -48,7 +48,7 @@ it 'returns repositories', vcr: false do get "/export/repositories", nil, admin_headers - + puts last_response.body expect(last_response.status).to eq(200) csv = last_response.body.lines expect(csv.length).to eq(2)