Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/datacite/lupo
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Jan 23, 2020
2 parents 983f26f + 5b59b1d commit 469ff6b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 20 deletions.
10 changes: 10 additions & 0 deletions app/models/doi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,16 @@ def self.query(query, options={})
options[:page][:number] ||= 1
options[:page][:size] ||= 25

if options[:totals_agg] == "provider"
aggregations = provider_aggregations
elsif options[:totals_agg] == "client"
aggregations = client_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.
if options.dig(:page, :cursor)
from = 0
Expand Down
39 changes: 19 additions & 20 deletions spec/requests/providers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,29 +96,28 @@
end
end

# describe 'GET /providers/totals' do
# let(:provider) { create(:provider) }
# let(:client) { create(:client, provider: provider) }
# let!(:prefixes) { create_list(:prefix, 10) }
# let!(:dois) { create_list(:doi, 3, client: client, aasm_state: "findable") }

# before do
# Provider.import
# Client.import
# sleep 2
# end
describe 'GET /providers/totals' do
let(:provider) { create(:provider) }
let(:client) { create(:client, provider: provider) }
let!(:prefixes) { create_list(:prefix, 10) }
let!(:dois) { create_list(:doi, 3, client: client, aasm_state: "findable") }

# it "returns providers" do
# get "/providers/totals", nil, headers
before do
Provider.import
Client.import
Doi.import
sleep 3
end

# puts last_response.body
it "returns providers" do
get "/providers/totals", nil, headers

# expect(last_response.status).to eq(200)
# expect(json['data'].size).to eq(4)
# expect(json.dig('meta', 'total')).to eq(4)
# expect(json.dig('meta')).to eq(4)
# end
# end
expect(last_response.status).to eq(200)
# expect(json['data'].size).to eq(4)
expect(json.first.dig('count')).to eq(3)
expect(json.first.dig('temporal')).not_to be_nil
end
end

describe 'POST /providers' do
context 'request is valid' do
Expand Down

0 comments on commit 469ff6b

Please sign in to comment.