Skip to content

Commit

Permalink
Change joss_id to journal_id
Browse files Browse the repository at this point in the history
  • Loading branch information
xuanxu committed Oct 10, 2023
1 parent 6b8b6d2 commit 1c73d7e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
12 changes: 6 additions & 6 deletions app/models/paper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,10 @@ def archive_doi_url
end
end

# A 5-figure integer used to produce the JOSS DOI
def joss_id
# A 5-figure integer used to produce the Journal DOI
def journal_id
if self.is_a_retraction_notice?
return retracted_paper.joss_id + "R"
return retracted_paper.journal_id + "R"
else
id = "%05d" % review_issue_id
return "#{setting(:abbreviation).downcase}.#{id}"
Expand All @@ -320,7 +320,7 @@ def joss_id
# version if no DOI is set.
def seo_url
if accepted?
"#{Rails.application.settings["url"]}/papers/10.21105/#{joss_id}"
"#{Rails.application.settings["url"]}/papers/10.21105/#{journal_id}"
else
"#{Rails.application.settings["url"]}/papers/#{to_param}"
end
Expand All @@ -337,7 +337,7 @@ def seo_pdf_url
def pdf_url
doi_to_file = doi.gsub('/', '.')

"#{Rails.application.settings["papers_html_url"]}/#{joss_id}/#{doi_to_file}.pdf"
"#{Rails.application.settings["papers_html_url"]}/#{journal_id}/#{doi_to_file}.pdf"
end

# 'reviewers' should be a string (and may be comma-separated)
Expand Down Expand Up @@ -501,7 +501,7 @@ def status_badge
end

def status_badge_url
"#{Rails.application.settings["url"]}/papers/10.21105/#{joss_id}/status.svg"
"#{Rails.application.settings["url"]}/papers/10.21105/#{journal_id}/status.svg"
end

def markdown_code
Expand Down
22 changes: 11 additions & 11 deletions lib/tasks/portico.rake
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,38 @@ namespace :portico do
task deposit: :environment do
Paper.visible.not_archived.each do |paper|
Net::SFTP.start(ENV['PORTICO_HOST'], ENV['PORTICO_USERNAME'], password: ENV['PORTICO_PASSWORD']) do |sftp|
if sftp.dir.glob("/", "10.21105.#{paper.joss_id}.zip").any?
puts "Deposit already exists for 10.21105.#{paper.joss_id}"
if sftp.dir.glob("/", "10.21105.#{paper.journal_id}.zip").any?
puts "Deposit already exists for 10.21105.#{paper.journal_id}"
else
crossref_file = "https://github.com/#{Rails.application.settings["papers_repo"]}/raw/master/#{paper.joss_id}/10.21105.#{paper.joss_id}.crossref.xml"
pdf_file = "https://github.com/#{Rails.application.settings["papers_repo"]}/raw/master/#{paper.joss_id}/10.21105.#{paper.joss_id}.pdf"
crossref_file = "https://github.com/#{Rails.application.settings["papers_repo"]}/raw/master/#{paper.journal_id}/10.21105.#{paper.journal_id}.crossref.xml"
pdf_file = "https://github.com/#{Rails.application.settings["papers_repo"]}/raw/master/#{paper.journal_id}/10.21105.#{paper.journal_id}.pdf"

files_to_download = [crossref_file, pdf_file]

# Create folder
`mkdir tmp/10.21105.#{paper.joss_id}`
`mkdir tmp/10.21105.#{paper.journal_id}`

# Download the files into this folder
files_to_download.each do |file|
`cd tmp/10.21105.#{paper.joss_id} && { curl -L -O #{file} ; cd -; }`
`cd tmp/10.21105.#{paper.journal_id} && { curl -L -O #{file} ; cd -; }`
end

# Archive the review too...
archive_review_object = Hash.new
archive_review_object['review_issue'] = GITHUB.issue(Rails.application.settings["reviews"], paper.review_issue_id).to_h
archive_review_object['review_issue_comments'] = GITHUB.issue_comments(Rails.application.settings["reviews"], paper.review_issue_id).map(&:to_h)

File.open("tmp/10.21105.#{paper.joss_id}/review.json", "w") { |f|
File.open("tmp/10.21105.#{paper.journal_id}/review.json", "w") { |f|
f.write(JSON.pretty_generate(archive_review_object))
}

# Zip the folder
`zip tmp/10.21105.#{paper.joss_id}.zip tmp/10.21105.#{paper.joss_id}/*`
sftp.upload("tmp/10.21105.#{paper.joss_id}.zip", "10.21105.#{paper.joss_id}.zip")
puts "Uploading deposit for 10.21105.#{paper.joss_id}"
`zip tmp/10.21105.#{paper.journal_id}.zip tmp/10.21105.#{paper.journal_id}/*`
sftp.upload("tmp/10.21105.#{paper.journal_id}.zip", "10.21105.#{paper.journal_id}.zip")
puts "Uploading deposit for 10.21105.#{paper.journal_id}"

# Clean up
`rm -rf tmp/10.21105.#{paper.joss_id}*`
`rm -rf tmp/10.21105.#{paper.journal_id}*`

# Update the paper
paper.update_attribute(:archived, true)
Expand Down

0 comments on commit 1c73d7e

Please sign in to comment.