Skip to content
Please note that GitHub no longer supports your web browser.

We recommend upgrading to the latest Google Chrome or Firefox.

Learn more
Permalink
Browse files

Keep track of whether a paper is archived

  • Loading branch information
arfon committed Sep 28, 2019
1 parent 87971fe commit 9ec0f482d916c740087099dbc77de53a59512847
Showing with 15 additions and 5 deletions.
  1. +1 −0 app/models/paper.rb
  2. +5 −0 db/migrate/20190928003647_add_archived_to_paper.rb
  3. +5 −4 db/schema.rb
  4. +4 −1 lib/tasks/portico.rake
@@ -91,6 +91,7 @@ class Paper < ActiveRecord::Base
scope :public_everything, lambda { where('state NOT IN (?)', ['submitted', 'rejected', 'withdrawn']) }
scope :everything, lambda { where('state NOT IN (?)', ['rejected', 'withdrawn']) }
scope :search_import, -> { where(state: VISIBLE_STATES) }
scope :not_archived, -> { where('archived = ?', false) }

before_create :set_sha, :set_last_activity
after_create :notify_editors, :notify_author
@@ -0,0 +1,5 @@
class AddArchivedToPaper < ActiveRecord::Migration[6.0]
def change
add_column :papers, :archived, :boolean, default: false
end
end
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2019_08_20_143831) do
ActiveRecord::Schema.define(version: 2019_09_28_003647) do

# These are extensions that must be enabled in order to support this database
enable_extension "hstore"
@@ -33,7 +33,7 @@
t.index ["user_id"], name: "index_editors_on_user_id"
end

create_table "papers", force: :cascade do |t|
create_table "papers", id: :serial, force: :cascade do |t|
t.string "title"
t.string "state"
t.string "repository_url"
@@ -49,17 +49,18 @@
t.text "paper_body"
t.integer "meta_review_issue_id"
t.string "suggested_editor"
t.string "kind"
t.text "authors"
t.text "citation_string"
t.datetime "accepted_at"
t.string "kind"
t.integer "editor_id"
t.string "reviewers", default: [], array: true
t.text "activities"
t.datetime "last_activity"
t.jsonb "labels", default: {}, null: false
t.text "metadata"
t.text "retraction_notice"
t.boolean "archived", default: false
t.index ["editor_id"], name: "index_papers_on_editor_id"
t.index ["labels"], name: "index_papers_on_labels", using: :gin
t.index ["last_activity"], name: "index_papers_on_last_activity"
@@ -68,7 +69,7 @@
t.index ["user_id"], name: "index_papers_on_user_id"
end

create_table "users", force: :cascade do |t|
create_table "users", id: :serial, force: :cascade do |t|
t.string "provider"
t.string "uid"
t.string "name"
@@ -3,7 +3,7 @@ require 'net/ftp'
namespace :portico do
desc "Deposit"
task deposit: :environment do
Paper.visible.each do |paper|
Paper.visible.not_archived.each do |paper|
# Upload to FTP server
Net::FTP.open(ENV['PORTICO_HOST'], ENV['PORTICO_USERNAME'], ENV['PORTICO_PASSWORD']) do |ftp|
if ftp.list("10.21105.#{paper.joss_id}.zip").any?
@@ -29,6 +29,9 @@ namespace :portico do

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

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

0 comments on commit 9ec0f48

Please sign in to comment.
You can’t perform that action at this time.