-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DOI minting for data and code pathway #1584
Changes from 3 commits
9cc4b05
e9fd42f
4b19128
62ab492
6e4a40f
921eb94
4c9c58b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,8 @@ | |
module Dashboard | ||
module Form | ||
class PublishController < BaseController | ||
class DoiIsMintingError < RuntimeError; end | ||
|
||
def edit | ||
@work_version = WorkVersion | ||
.includes(file_version_memberships: [:file_resource]) | ||
|
@@ -32,6 +34,9 @@ def update | |
@resource.indexing_source = Proc.new { nil } | ||
@resource.save | ||
@resource.publish | ||
if @resource.mint_doi_requested | ||
allow_mint_doi? ? MintDoiAsync.call(@resource.work) : flash[:error] = t('dashboard.form.publish.doi.error') | ||
end | ||
elsif request_curation? && [email protected]_curation_requested | ||
@resource.update_column(:draft_curation_requested, true) | ||
# We want validation errors to block curation requests and keep users on the edit page | ||
|
@@ -115,6 +120,7 @@ def work_version_params | |
:published_date, | ||
:depositor_agreement, | ||
:draft_curation_requested, | ||
:mint_doi_requested, | ||
keyword: [], | ||
contributor: [], | ||
publisher: [], | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,10 @@ def allows_curation_request? | |
data_and_code? && [email protected]_curation_requested | ||
end | ||
|
||
def allows_mint_doi_request? | ||
data_and_code? && @resource.work.doi.blank? && !DoiMintingStatus.new(@resource.work).present? | ||
end | ||
|
||
def work? | ||
Work::Types.all.include?(work_type) | ||
end | ||
|
@@ -117,6 +121,7 @@ def imported_metadata_from_rmd? | |
:update_doi=, | ||
:work_type, | ||
:draft_curation_requested, | ||
:mint_doi_requested, | ||
to: :work_version, prefix: false | ||
|
||
private | ||
|
@@ -258,6 +263,7 @@ def form_partial | |
:aasm, | ||
:update_column, | ||
:draft_curation_requested=, | ||
:mint_doi_requested=, | ||
:set_thumbnail_selection, | ||
to: :work_version, | ||
prefix: false | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ class DoiMintingJob < ApplicationJob | |
queue_as :doi | ||
|
||
def perform(resource) | ||
sleep(2) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What was the difference in behavior that you said that you saw when you omitted this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So test environment is fine either way, but in local dev & the preview branch, without the sleep, v1 work versions do not successfully mint a doi. It will mint one on v2 of the same work successfully though. I had trouble figuring out why this is because it is hitting the DoiMintingJob but not throwing any type of error that I can tell. I only found out the sleep works because I put in a byebug to dig further & it worked that time so I replaced it with a sleep & then everything worked as expected. Also why my suspicion is that it's something around timing with when it sends the record data to data cite. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Though that being said, this is the only spot the sleep made a difference. I also tried one before There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I was able to get this to work locally without the sleep by disabling ActiveJob in the config for the dev environments: https://github.com/psu-libraries/scholarsphere/blob/main/config/environments/development.rb#L19-L20 Looks like we override SideKiq in the development environment and just use ActiveJob instead. The minting still failed for me, but I think it's rejecting my url because it's a localhost url. But the job queued and ran. This doesn't explain why it's not working on the preview branch, though. It should be using SideKiq there. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, I don't know why it works with SideKiq but not ActiveJob. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah I see Eric has a fix for this. Using SideKiq probably just delayed the job enough to mimic what the sleep was doing. My comments can be ignored. |
||
status = DoiMintingStatus.new(resource) | ||
|
||
status.minting! | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<div class="form-group mt-5"> | ||
<div class="keyline keyline--left"> | ||
<h4><%= t '.header' %></h4> | ||
</div> | ||
<div> | ||
<div> | ||
<%= t '.request_description' %> | ||
</div> | ||
<br> | ||
<div class="form-check"> | ||
<%= form.check_box :mint_doi_requested, | ||
required: false, | ||
class: 'form-check-input' %> | ||
|
||
<%= form.label :mint_doi_requested, class: 'form-check-label' do %> | ||
<%= t '.label' %> | ||
<% end %> | ||
</div> | ||
</div> | ||
</div> |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this information actually need to be saved to the database? In other words, do we ever need to recall it from the database after it has been saved? Or do we only care about it for the duration of the request where this form field is submitted? Could it simply be added as a transient attribute on Or maybe it doesn't even need to be an attribute of I'm asking as if I actually know the answer, but I don't. I don't immediately see why this would need to be saved, but there might be a reason that I don't know about. I just wanted to make sure that it was something that you considered. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So I was debating about that as well. I landed on saving it since users can save & exit the form and come back later to publish. My instinct was that users who previously checked the box might assume it was still checked, submit without rechecking, and incorrectly think they're minting a doi upon publish. I could still go either way though & am open to suggestion. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah! I hadn't thought of that, and it totally makes sense. You're way ahead of me. 🤐 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddMintDoiRequestedToWorkVersion < ActiveRecord::Migration[6.1] | ||
def change | ||
add_column :work_versions, :mint_doi_requested, :boolean | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest two refactorings here.
The first one is trivial and also much less important, but I think that the code would read a little better if we implemented
DoiMintingStatus#blank?
and used that here instead of!
and#present?
.The second and more important thing is that I'd try to get rid of the method chaining here.
WorkDepositPathway
needs to know too much about the resource object that it's holding. It needs to know that the resource has a work and that the work in turn can have a DOI. It would be better if each type of thing that might act as a resource here (maybe it's onlyWorkVersion
? I can't remember..) could handle telling the work deposit pathway whether or not it has a DOI directly - i.e.@resource.doi_blank?
. That reads better too, but it also relievesWorkDepositPathway
of needing to know about the structure/hierarchy of that other information.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First one I agree though as a note,
#present?
here is not a normal present. It's actually a custom method ofDoiMintingStatus
(threw me off for a long time trying to troubleshoot because#present?
and#blank?
were both returning false). But thinking on it, I can also just do a custom#blank?
on DoiMintingStatus so we can still follow typical conventions.Second sounds good & I'll get working on that.