Skip to content

Commit

Permalink
remove obsolete mds maintenance tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Dec 23, 2018
1 parent af4c368 commit 331de0a
Show file tree
Hide file tree
Showing 15 changed files with 6 additions and 311 deletions.
17 changes: 0 additions & 17 deletions app/controllers/client_prefixes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,23 +108,6 @@ def destroy
head :no_content
end

def set_created
authorize! :update, ClientPrefix
ClientPrefix.where(created_at: nil).find_each do |cp|
cp.update_column(:created_at, cp.prefix.created)
end
render json: { message: "Client prefix created timestamp added." }.to_json, status: :ok
end

def set_provider
authorize! :update, ClientPrefix
ClientPrefix.where(allocator_prefixes: nil).find_each do |cp|
cp.send(:set_allocator_prefixes)
cp.save
end
render json: { message: "Client prefix associated provider prefix added." }.to_json, status: :ok
end

protected

def set_include
Expand Down
13 changes: 0 additions & 13 deletions app/controllers/dois_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -341,26 +341,13 @@ def destroy
end
end

def status
doi = Doi.where(doi: params[:id]).first
status = Doi.get_landing_page_info(doi: doi, url: params[:url])
render json: status.to_json, status: :ok
end

def random
prefix = params[:prefix].presence || "10.5072"
doi = generate_random_doi(prefix, number: params[:number])

render json: { doi: doi }.to_json
end

def set_state
authorize! :set_state, Doi

Doi.set_state
render json: { message: "DOI state updated." }.to_json, status: :ok
end

def get_url
authorize! :get_url, @doi

Expand Down
1 change: 0 additions & 1 deletion app/controllers/prefixes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ def set_include

private

# Use callbacks to share common setup or constraints between actions.
def set_prefix
@prefix = Prefix.where(prefix: params[:id]).first

Expand Down
8 changes: 0 additions & 8 deletions app/controllers/provider_prefixes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,6 @@ def destroy
head :no_content
end

def set_created
authorize! :update, ProviderPrefix
ProviderPrefix.where(created_at: nil).find_each do |pp|
pp.update_column(:created_at, pp.prefix.created)
end
render json: { message: "Provider prefix created timestamp added." }.to_json, status: :ok
end

protected

def set_include
Expand Down
34 changes: 0 additions & 34 deletions app/models/concerns/checkable.rb

This file was deleted.

20 changes: 0 additions & 20 deletions app/models/doi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ class Doi < ActiveRecord::Base
# include helper module for converting and exposing metadata
include Crosscitable

# include helper module for link checking
include Checkable

# include state machine
include AASM

Expand Down Expand Up @@ -644,23 +641,6 @@ def event=(value)
self.send(value) if %w(register publish hide).include?(value)
end

# update state for all DOIs in state "" starting from from_date
def self.set_state(from_date: nil)
from_date ||= Time.zone.now - 1.day
Doi.where("updated >= ?", from_date).where(aasm_state: '').find_each do |doi|
if doi.is_test_prefix? || (doi.is_active.getbyte(0) == 0 && doi.minted.blank?)
state = "draft"
elsif doi.is_active.to_s.getbyte(0) == 0 && doi.minted.present?
state = "registered"
else
state = "findable"
end
UpdateStateJob.perform_later(doi.doi, state: state)
end
rescue ActiveRecord::LockWaitTimeout => exception
Bugsnag.notify(exception)
end

# delete all DOIs with test prefix 10.5072 not updated since from_date
# we need to use destroy_all to also delete has_many associations for metadata and media
def self.delete_test_dois(from_date: nil)
Expand Down
1 change: 1 addition & 0 deletions config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ mysql: &mysql
defaults: &defaults
pool: <%= ENV['CONCURRENCY'].to_i + 5 %>
timeout: 5000
wait_timeout: 1800
encoding: utf8mb4
username: <%= ENV['MYSQL_USER'] %>
password: <%= ENV['MYSQL_PASSWORD'] %>
Expand Down
1 change: 0 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
# manage DOIs
post 'dois/validate', :to => 'dois#validate'
post 'dois/status', :to => 'dois#status'
post 'dois/set-state', :to => 'dois#set_state'
post 'dois/set-minted', :to => 'dois#set_minted'
post 'dois/set-url', :to => 'dois#set_url'
post 'dois/delete-test-dois', :to => 'dois#delete_test_dois'
Expand Down
6 changes: 0 additions & 6 deletions lib/tasks/doi.rake
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,6 @@ namespace :doi do
puts "DOIs created on #{from_date} indexed."
end

desc 'Set state'
task :set_state => :environment do
from_date = ENV['FROM_DATE'] || Time.zone.now - 1.day
Doi.set_state(from_date: from_date)
end

desc 'Set minted'
task :set_minted => :environment do
from_date = ENV['FROM_DATE'] || Time.zone.now - 1.day
Expand Down
41 changes: 0 additions & 41 deletions lib/tasks/prefix.rake

This file was deleted.

58 changes: 0 additions & 58 deletions spec/concerns/checkable_spec.rb

This file was deleted.

24 changes: 0 additions & 24 deletions spec/requests/client_prefixes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,28 +122,4 @@
end
end
end

describe 'POST /client-prefixes/set-created' do
before { post '/client-prefixes/set-created', headers: headers }

it 'returns success' do
expect(json['message']).to eq("Client prefix created timestamp added.")
end

it 'returns status code 200' do
expect(response).to have_http_status(200)
end
end

describe 'POST /client-prefixes/set-provider' do
before { post '/client-prefixes/set-provider', headers: headers }

it 'returns success' do
expect(json['message']).to eq("Client prefix associated provider prefix added.")
end

it 'returns status code 200' do
expect(response).to have_http_status(200)
end
end
end
72 changes: 0 additions & 72 deletions spec/requests/dois_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1938,18 +1938,6 @@
end
end

describe 'POST /dois/set-state' do
before { post '/dois/set-state', headers: admin_headers }

it 'returns dois' do
expect(json['message']).to eq("DOI state updated.")
end

it 'returns status code 200' do
expect(response).to have_http_status(200)
end
end

describe 'POST /dois/set-minted' do
let(:provider) { create(:provider, symbol: "ETHZ") }
let(:client) { create(:client, provider: provider) }
Expand Down Expand Up @@ -2122,66 +2110,6 @@
end
end

describe 'POST /dois/status', vcr: true do
let(:doi) { create(:doi, url: "https://blog.datacite.org/re3data-science-europe/") }

before { post "/dois/status?id=#{doi.doi}", headers: headers }

it 'returns landing page status' do
expect(json['status']).to eq(200)
expect(json['content-type']).to eq("text/html")
end

it 'returns status code 200' do
expect(response).to have_http_status(200)
end
end

describe 'POST /dois/status pdf', vcr: true do
let(:doi) { create(:doi, url: "https://schema.datacite.org/meta/kernel-4.1/doc/DataCite-MetadataKernel_v4.1.pdf") }

before { post "/dois/status?id=#{doi.doi}", headers: headers }

it 'returns landing page status' do
expect(json['status']).to eq(200)
expect(json['content-type']).to eq("application/pdf")
end

it 'returns status code 200' do
expect(response).to have_http_status(200)
end
end

describe 'POST /dois/status no doi', vcr: true do
let(:url) { "https://blog.datacite.org/re3data-science-europe/" }

before { post "/dois/status?url=#{url}", headers: headers }

it 'returns landing page status' do
expect(json['status']).to eq(200)
expect(json['content-type']).to eq("text/html")
end

it 'returns status code 200' do
expect(response).to have_http_status(200)
end
end

describe 'POST /dois/status no doi pdf', vcr: true do
let(:url) { "https://schema.datacite.org/meta/kernel-4.1/doc/DataCite-MetadataKernel_v4.1.pdf" }

before { post "/dois/status?url=#{url}", headers: headers }

it 'returns landing page status' do
expect(json['status']).to eq(200)
expect(json['content-type']).to eq("application/pdf")
end

it 'returns status code 200' do
expect(response).to have_http_status(200)
end
end

describe 'GET /dois/DOI/get-url', vcr: true do
let(:doi) { create(:doi, client: client, doi: "10.5438/fj3w-0shd", url: "https://blog.datacite.org/data-driven-development/", event: "publish") }

Expand Down
Loading

0 comments on commit 331de0a

Please sign in to comment.