From 29205bc1b22241ab4993b967a9d84130feff7111 Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Fri, 17 May 2019 00:02:32 +0200 Subject: [PATCH] support usage reports from test system. #260 --- app/models/usage_report.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/models/usage_report.rb b/app/models/usage_report.rb index 102018238..1ad11794d 100644 --- a/app/models/usage_report.rb +++ b/app/models/usage_report.rb @@ -5,7 +5,8 @@ class UsageReport include Modelable def self.find_by_id(id) - url = "https://api.datacite.org/reports/#{id}" + url = Rails.env.production? ? "https://api.datacite.org/reports/#{id}" : "https://api.test.datacite.org/reports/#{id}" + response = Maremma.get(url) return {} if response.status != 200 @@ -22,8 +23,8 @@ def self.query(query, options={}) number = (options.dig(:page, :number) || 1).to_i size = (options.dig(:page, :size) || 25).to_i - url = "https://api.datacite.org/reports?page[size]=#{size}&page[number]=#{number}" - + url = Rails.env.production? ? "https://api.datacite.org/reports?page[size]=#{size}&page[number]=#{number}" : "https://api.test.datacite.org/reports?page[size]=#{size}&page[number]=#{number}" + response = Maremma.get(url) return {} if response.status != 200