Skip to content

Commit

Permalink
put updated findable dois on message queue. datacite/levriero#33
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Oct 6, 2018
1 parent f59f103 commit a2f00f0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 23 deletions.
2 changes: 1 addition & 1 deletion app/models/concerns/indexable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module Indexable
logger = Logger.new(STDOUT)
logger.info "[Elasticsearch] Indexing of DOI #{doi} finished #{index_interval.to_s} seconds after DOI update."

# send_import_message(self.to_jsonapi)
send_import_message(self.to_jsonapi) if aasm_state == "findable"
end
end

Expand Down
19 changes: 1 addition & 18 deletions app/models/doi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Doi < ActiveRecord::Base
include Elasticsearch::Model

aasm :whiny_transitions => false do
# draft is initial istate for new DOIs.
# draft is initial state for new DOIs.
state :draft, :initial => true
state :tombstoned, :registered, :findable, :flagged, :broken

Expand Down Expand Up @@ -366,25 +366,8 @@ def update_media
def to_jsonapi
attributes = {
"doi" => doi,
"identifier" => identifier,
"url" => url,
"creator" => author,
"title" => title,
"publisher" => publisher,
"resource-type-subtype" => additional_type,
"version" => version,
"schema-version" => schema_version,
"metadata-version" => metadata_version,
"client-id" => client_id,
"provider-id" => provider_id,
"resource-type-id" => resource_type_general,
"prefix" => prefix,
"state" => aasm_state,
"source" => source,
"is-active" => is_active == "\x01",
"created" => created,
"published" => date_published,
"registered" => date_registered,
"updated" => date_updated }

{ "id" => doi, "type" => "dois", "attributes" => attributes }
Expand Down
7 changes: 3 additions & 4 deletions spec/models/doi_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,9 @@
it "works" do
params = doi.to_jsonapi
expect(params.dig("id")).to eq(doi.doi)
expect(params.dig("attributes","url")).to eq(doi.url)
expect(params.dig("attributes","resource-type-id")).to eq("Text")
expect(params.dig("attributes","schema-version")).to eq("http://datacite.org/schema/kernel-3")
expect(params.dig("attributes","is-active")).to be false
expect(params.dig("attributes","state")).to eq("draft")
expect(params.dig("attributes","created")).to eq(doi.created)
expect(params.dig("attributes","updated")).to eq(doi.updated)
end
end

Expand Down

0 comments on commit a2f00f0

Please sign in to comment.