Skip to content

Commit

Permalink
move dois missing report to different api. #676
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Nov 27, 2020
1 parent 9f4aa94 commit b16a95e
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 60 deletions.
7 changes: 7 additions & 0 deletions app/controllers/exports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,13 @@ def repositories
status: :bad_request
end

def check_indexed_dois
csv = Client.export_doi_counts
filename = "repositories-not-fully-indexed-#{Date.today}.csv"

send_data csv, filename: filename
end

def export_date(date)
DateTime.strptime(date, "%Y-%m-%dT%H:%M:%S").strftime(
"%d/%m/%YT%H:%M:%S.%3NUTC%:z",
Expand Down
7 changes: 0 additions & 7 deletions app/controllers/repositories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -307,13 +307,6 @@ def stats
render json: meta, status: :ok
end

def check_links
csv = Client.export_doi_counts
filename = "repositories-not-fully-indexed-#{Date.today}.csv"

send_data csv, filename: filename
end

protected
def set_include
if params[:include].present?
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
get "export/repositories",
to: "exports#repositories", defaults: { format: :csv }
get "export/contacts", to: "exports#contacts", defaults: { format: :csv }
get "repositories/check-links", to: "repositories#check_links"
get "export/check-indexed-dois", to: "exports#check_indexed_dois"

resources :heartbeat, only: %i[index]

Expand Down
28 changes: 28 additions & 0 deletions spec/requests/exports_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -229,4 +229,32 @@
)
end
end

describe "GET /export/check-indexed-dois", elasticsearch: true do
let(:client) do
create(
:client,
provider: provider,
symbol: "UVA.LIBRARY",
name: "University of Virginia Library",
)
end
let!(:dois) { create_list(:doi, 3, client: client, aasm_state: "findable") }

before do
DataciteDoi.import
Client.import
sleep 2
end

it "returns repositories with dois not indexed", vcr: false do
get "/export/check-indexed-dois",
nil, admin_headers
puts last_response.body
expect(last_response.status).to eq(200)
csv = last_response.body.lines
expect(csv.length).to eq(1)
expect(csv[0].strip).to be_blank
end
end
end
52 changes: 0 additions & 52 deletions spec/requests/repositories_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -625,56 +625,4 @@
# expect(Doi.query(nil, client_id: target.symbol.downcase).results.total).to eq(3)
end
end

describe "GET /repositories/check-links", elasticsearch: true do
let(:admin_bearer) { User.generate_token }
let(:admin_headers) do
{
"HTTP_ACCEPT" => "text/csv",
"HTTP_AUTHORIZATION" => "Bearer " + admin_bearer,
}
end
let(:consortium) do
create(
:provider,
role_name: "ROLE_CONSORTIUM",
name: "Virtual Library of Virginia",
symbol: "VIVA",
)
end
let!(:provider) do
create(
:provider,
role_name: "ROLE_CONSORTIUM_ORGANIZATION",
name: "University of Virginia",
symbol: "UVA",
consortium: consortium,
)
end
let(:client) do
create(
:client,
provider: provider,
symbol: "UVA.LIBRARY",
name: "University of Virginia Library",
)
end
let!(:dois) { create_list(:doi, 3, client: client, aasm_state: "findable") }

before do
DataciteDoi.import
Client.import
sleep 2
end

it "returns repositories with dois not indexed", vcr: false do
get "/repositories/check-links",
nil, admin_headers
puts last_response.body
expect(last_response.status).to eq(200)
csv = last_response.body.lines
expect(csv.length).to eq(1)
expect(csv[0].strip).to be_blank
end
end
end

0 comments on commit b16a95e

Please sign in to comment.