Skip to content

Commit

Permalink
Merge pull request #77 from datacite/refactor_use_stage_env
Browse files Browse the repository at this point in the history
Refactor use stage env
  • Loading branch information
kjgarza authored Jun 15, 2020
2 parents 4b58815 + 9d4d219 commit 9be23ff
Show file tree
Hide file tree
Showing 61 changed files with 668 additions and 151 deletions.
2 changes: 1 addition & 1 deletion app/models/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def send_notification_to_slack(text, options={})
end

def self.doi_from_url(url)
if /\A(?:(http|https):\/\/(dx\.)?(doi.org|handle.test.datacite.org)\/)?(doi:)?(10\.\d{4,5}\/.+)\z/.match(url)
if /\A(?:(http|https):\/\/(dx\.)?(doi.org|handle.test.datacite.org|handle.stage.datacite.org)\/)?(doi:)?(10\.\d{4,5}\/.+)\z/.match(url)
uri = Addressable::URI.parse(url)
uri.path.gsub(/^\//, '').downcase
end
Expand Down
12 changes: 9 additions & 3 deletions app/models/report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,18 @@ def initialize report, options={}

def self.parse_multi_subset_report report
subset = report.subsets.last

#puts subset["checksum"]

compressed = decode_report subset["gzip"]
json = decompress_report compressed
dataset_array = parse_subset json
url = Rails.env.production? ? "https://api.datacite.org/reports/#{report.report_id}" : "https://api.test.datacite.org/reports/#{report.report_id}"
url = case true
when Rails.env.production?
"https://api.datacite.org/reports/#{report.report_id}"
when ENV["API_URL"].include?("test")
"https://api.test.datacite.org/reports/#{report.report_id}"
else
"https://api.stage.datacite.org/reports/#{report.report_id}"
end
dataset_array.map do |dataset|
args = {header: report.header, url: url}
UsageUpdateParseJob.perform_later(dataset, args)
Expand Down
8 changes: 4 additions & 4 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
ENV['CONCURRENCY'] ||= "25"
ENV['GITHUB_URL'] ||= "https://github.com/datacite/levriero"
ENV['ORCID_API_URL'] ||= "https://pub.orcid.org/v2.1"
ENV['API_URL'] ||= "https://api.test.datacite.org"
ENV['VOLPINO_URL'] ||= "https://api.test.datacite.org"
ENV['LAGOTTINO_URL'] ||= "https://api.test.datacite.org"
ENV['SASHIMI_QUERY_URL'] ||= "https://api.test.datacite.org"
ENV['API_URL'] ||= "https://api.stage.datacite.org"
ENV['VOLPINO_URL'] ||= "https://api.stage.datacite.org"
ENV['LAGOTTINO_URL'] ||= "https://api.stage.datacite.org"
ENV['SASHIMI_QUERY_URL'] ||= "https://api.stage.datacite.org"
ENV['EVENTDATA_URL'] ||= "https://bus-staging.eventdata.crossref.org"
ENV['CROSSREF_QUERY_URL'] ||= "https://api.eventdata.crossref.org"
ENV['TRUSTED_IP'] ||= "10.0.40.1"
Expand Down
4 changes: 2 additions & 2 deletions spec/fixtures/event_data_resp_1
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
https://api.test.datacite.org/reports/2018-3-Dash total-dataset-investigations-regular https://doi.org/10.7291/d1q94r pushed to Event Data service.
https://api.test.datacite.org/reports/2018-3-Dash unique-dataset-investigations-regular https://doi.org/10.7291/d1q94r pushed to Event Data service.
https://api.stage.datacite.org/reports/2018-3-Dash total-dataset-investigations-regular https://doi.org/10.7291/d1q94r pushed to Event Data service.
https://api.stage.datacite.org/reports/2018-3-Dash unique-dataset-investigations-regular https://doi.org/10.7291/d1q94r pushed to Event Data service.
8 changes: 4 additions & 4 deletions spec/fixtures/event_data_resp_2
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
https://api.test.datacite.org/reports/2018-3-Dash total-dataset-investigations-regular https://doi.org/10.7291/d1q94r had an error:\nthe server responded with status 500/\n
https://api.test.datacite.org/reports/2018-3-Dash unique-dataset-investigations-regular https://doi.org/10.7291/d1q94r had an error:\nthe server responded with status 500/\n
https://api.test.datacite.org/reports/2018-3-Dash Total-Dataset-Requests-Machine https://doi.org/10.6071/z7wc73 had an error:\nthe server responded with status 500/\n
https://api.test.datacite.org/reports/2018-3-Dash Unique-Dataset-Requests-Machine https://doi.org/10.6071/z7wc73 had an error:\nthe server responded with status 500/\n
https://api.stage.datacite.org/reports/2018-3-Dash total-dataset-investigations-regular https://doi.org/10.7291/d1q94r had an error:\nthe server responded with status 500/\n
https://api.stage.datacite.org/reports/2018-3-Dash unique-dataset-investigations-regular https://doi.org/10.7291/d1q94r had an error:\nthe server responded with status 500/\n
https://api.stage.datacite.org/reports/2018-3-Dash Total-Dataset-Requests-Machine https://doi.org/10.6071/z7wc73 had an error:\nthe server responded with status 500/\n
https://api.stage.datacite.org/reports/2018-3-Dash Unique-Dataset-Requests-Machine https://doi.org/10.6071/z7wc73 had an error:\nthe server responded with status 500/\n
4 changes: 2 additions & 2 deletions spec/fixtures/events_empty.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
}, {
"uuid": "fc6860b8-4230-41bc-8b8e-21d60e9a7d9a",
"message-action": "create",
"subj-id": "https://api.test.datacite.org/reports/2018-3-Dashs",
"subj-id": "https://api.stage.datacite.org/reports/2018-3-Dashs",
"subj": {
"id": "https://api.test.datacite.org/reports/2018-3-Dashs",
"id": "https://api.stage.datacite.org/reports/2018-3-Dashs",
"issued": "2128-04-09"
},
"total": 3,
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/usage_event.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"report_id":"https://api.test.datacite.org/reports/5cac6ca0-9391-4e1d-95cf-ba2f475cbfad"}
{"report_id":"https://api.stage.datacite.org/reports/5cac6ca0-9391-4e1d-95cf-ba2f475cbfad"}
2 changes: 1 addition & 1 deletion spec/fixtures/usage_event_fail.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": 12332423432432,
"message-action": "create",
"subj": {
"id": "https://api.test.datacite.org/reports/2018-3-Dash",
"id": "https://api.stage.datacite.org/reports/2018-3-Dash",
"issued": "2128-04-09"
},
"total": "208",
Expand Down
16 changes: 8 additions & 8 deletions spec/fixtures/usage_events.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
{
"uuid": "a17e783b-8214-451e-9b0d-077213c2acae",
"message-action": "create",
"subj-id": "https://api.test.datacite.org/reports/2018-3-Dash",
"subj-id": "https://api.stage.datacite.org/reports/2018-3-Dash",
"subj": {
"id": "https://api.test.datacite.org/reports/2018-3-Dash",
"id": "https://api.stage.datacite.org/reports/2018-3-Dash",
"issued": "2128-04-09"
},
"total": 3,
Expand All @@ -17,9 +17,9 @@
}, {
"uuid": "fc6860b8-4230-41bc-8b8e-21d60e9a7d9a",
"message-action": "create",
"subj-id": "https://api.test.datacite.org/reports/2018-3-Dash",
"subj-id": "https://api.stage.datacite.org/reports/2018-3-Dash",
"subj": {
"id": "https://api.test.datacite.org/reports/2018-3-Dash",
"id": "https://api.stage.datacite.org/reports/2018-3-Dash",
"issued": "2128-04-09"
},
"total": 3,
Expand All @@ -32,9 +32,9 @@
}, {
"uuid": "054da0ad-9821-492e-877e-5c3adbfd5ccf",
"message-action": "create",
"subj-id": "https://api.test.datacite.org/reports/2018-3-Dash",
"subj-id": "https://api.stage.datacite.org/reports/2018-3-Dash",
"subj": {
"id": "https://api.test.datacite.org/reports/2018-3-Dash",
"id": "https://api.stage.datacite.org/reports/2018-3-Dash",
"issued": "2128-04-09"
},
"total": 254,
Expand All @@ -47,9 +47,9 @@
}, {
"uuid": "6d6fd620-2123-42da-91f3-6c02e63f3cec",
"message-action": "create",
"subj-id": "https://api.test.datacite.org/reports/2018-3-Dash",
"subj-id": "https://api.stage.datacite.org/reports/2018-3-Dash",
"subj": {
"id": "https://api.test.datacite.org/reports/2018-3-Dash",
"id": "https://api.stage.datacite.org/reports/2018-3-Dash",
"issued": "2128-04-09"
},
"total": 208,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9be23ff

Please sign in to comment.