From 97ea00f6e6679633e693545eb477a78538979c5b Mon Sep 17 00:00:00 2001 From: Kristian Garza Date: Wed, 7 Aug 2019 14:20:25 +0200 Subject: [PATCH] fix test and list of unique results --- app/models/event.rb | 2 +- spec/requests/events_spec.rb | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/models/event.rb b/app/models/event.rb index 14efbbd8c..7d937bb07 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -246,7 +246,7 @@ def self.metrics_aggregations filter: {script: {script: "#{INCLUDED_RELATION_TYPES}.contains(doc['relation_type_id'].value)"} }, aggs: { dois: { - terms: { field: 'doi', size: 50, min_doc_count: 1 }, aggs: { unique_citations: { cardinality: { field: 'citation_id' }}} + terms: { field: 'doi', size: 100, min_doc_count: 1 }, aggs: { unique_citations: { cardinality: { field: 'citation_id' }}} }} }, views: { diff --git a/spec/requests/events_spec.rb b/spec/requests/events_spec.rb index 384a16b07..a903f0f82 100644 --- a/spec/requests/events_spec.rb +++ b/spec/requests/events_spec.rb @@ -656,7 +656,7 @@ context "unique citations for a list of dois" do let!(:event) { create_list(:event_for_datacite_related, 50) } let!(:copies) { create(:event_for_datacite_related, subj_id:"http://doi.org/10.0260/co.2004960.v1", relation_type_id: "cites") } - let(:dois) {"10.5061/dryad.47sd5e/2,10.5061/dryad.47sd5e/3,10.5061/dryad.47sd5e/4,10.0260/co.2004960.v1"} + let(:dois) { ((event.map{ |e| e['subj_id'].gsub("https://doi.org/","")})[1, 20]).join(",")} let(:uri) { "/events?aggregations=metrics_aggregations&dois=#{dois}" } before do @@ -678,8 +678,7 @@ total = response.dig("meta", "total") expect(total).to eq(51) - # TODO - # expect((citations.select { |doi| dois.split(",").include?(doi["id"]) }).length).to eq(4) + expect((citations.select { |doi| dois.split(",").include?(doi["id"]) }).length).to eq(20) end end