Skip to content

Commit

Permalink
Don't let the adhoc status fly store the results.
Browse files Browse the repository at this point in the history
This should be handled by the dedicated crawler
  • Loading branch information
richardhallett committed Nov 9, 2018
1 parent a2a2bc9 commit 7d85bad
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
10 changes: 3 additions & 7 deletions app/models/concerns/checkable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,15 @@ def get_landing_page_info(doi: nil, url: nil, keep: true)

checked = Time.zone.now

doi.update_columns(last_landing_page_status: response.status,
last_landing_page_content_type: content_type,
last_landing_page_status_check: checked) if doi.present?

{ "status" => response.status,
"content-type" => content_type,
"checked" => checked.utc.iso8601 }
rescue URI::InvalidURIError => e
logger = Logger.new(STDOUT)
logger.error e.message
{ "status" => 404,
"content_type" => nil,

{ "status" => 404,
"content_type" => nil,
"checked" => Time.zone.now.utc.iso8601 }
end
end
Expand Down
6 changes: 0 additions & 6 deletions spec/concerns/checkable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,31 +34,25 @@
response = Doi.get_landing_page_info(doi: doi)
expect(response["status"]).to eq(200)
expect(response["content-type"]).to eq("text/html")
expect(doi.last_landing_page_status).to eq(200)
expect(doi.last_landing_page_content_type).to eq("text/html")
end

it 'content type pdf' do
doi = create(:doi, url: "https://schema.datacite.org/meta/kernel-4.1/doc/DataCite-MetadataKernel_v4.1.pdf")
response = Doi.get_landing_page_info(doi: doi)
expect(response["status"]).to eq(200)
expect(response["content-type"]).to eq("application/pdf")
expect(doi.last_landing_page_status).to eq(200)
expect(doi.last_landing_page_content_type).to eq("application/pdf")
end

it 'not found' do
doi = create(:doi, url: "https://blog.datacite.org/xxx")
response = Doi.get_landing_page_info(doi: doi)
expect(response["status"]).to eq(404)
expect(doi.last_landing_page_status).to eq(404)
end

it 'no url' do
doi = create(:doi, url: nil)
response = Doi.get_landing_page_info(doi: doi)
expect(response["status"]).to eq(404)
expect(doi.last_landing_page_status).to eq(nil)
end
end
end

0 comments on commit 7d85bad

Please sign in to comment.