-
Notifications
You must be signed in to change notification settings - Fork 0
Validate for DDBJ Record and updating accession #1405
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| class AccessionRenewals::FilesController < ApplicationController | ||
| def show | ||
| renewal = current_user.accession_renewals.find(params.expect(:accession_renewal_id)) | ||
|
|
||
| redirect_to renewal.file.url, allow_other_host: true | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| class AccessionRenewalsController < ApplicationController | ||
| def show | ||
| @renewal = current_user.accession_renewals.find(params.expect(:id)) | ||
| end | ||
|
|
||
| def create | ||
| accession = current_user.accessions.find_by!(number: params.expect(:accession_number)) | ||
| @renewal = accession.renewals.create!(renewal_params) | ||
|
|
||
| RenewAccessionJob.perform_later @renewal | ||
|
|
||
| render :show, status: :created | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def renewal_params | ||
| params.expect(accession_renewal: [ | ||
| :file | ||
| ]) | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,26 @@ | ||||
| class RenewAccessionJob < ApplicationJob | ||||
| def perform(renewal) | ||||
| renewal.update! progress: :running, started_at: Time.current | ||||
|
|
||||
| sleep 3 | ||||
|
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.
Suggested change
|
||||
|
|
||||
| ActiveRecord::Base.transaction do | ||||
| begin | ||||
| JSON.parse renewal.file.download | ||||
| rescue JSON::ParserError => e | ||||
| renewal.validation_details.create!( | ||||
| severity: 'error', | ||||
| message: e.message | ||||
| ) | ||||
| end | ||||
|
|
||||
| if renewal.validation_details.empty? | ||||
| renewal.validity_valid! | ||||
| else | ||||
| renewal.validity_invalid! | ||||
| end | ||||
| end | ||||
| ensure | ||||
| renewal.update! progress: :finished, finished_at: Time.current unless renewal.canceled? | ||||
| end | ||||
| end | ||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| class Accession < ApplicationRecord | ||
| belongs_to :submission | ||
|
|
||
| has_many :renewals, dependent: :destroy, class_name: 'AccessionRenewal' | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| class AccessionRenewal < ApplicationRecord | ||
| belongs_to :accession, inverse_of: :renewals | ||
|
|
||
| has_many :validation_details, dependent: :destroy, class_name: 'AccessionRenewalValidationDetail', inverse_of: :renewal | ||
|
|
||
| has_one_attached :file | ||
|
|
||
| enum :progress, %w[waiting running finished canceled].index_by(&:to_sym) | ||
| enum :validity, %w[valid invalid error].index_by(&:to_sym), prefix: true | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| class AccessionRenewalValidationDetail < ApplicationRecord | ||
| belongs_to :renewal, class_name: 'AccessionRenewal' | ||
| end |
2 changes: 1 addition & 1 deletion
2
app/models/database/bioproject/validator.rb → ...els/database/bioproject/file_validator.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
app/models/database/biosample/validator.rb → ...dels/database/biosample/file_validator.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
app/models/database/dra/validator.rb → app/models/database/dra/file_validator.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
app/models/database/gea/validator.rb → app/models/database/gea/file_validator.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
app/models/database/jvar/validator.rb → app/models/database/jvar/file_validator.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
app/models/database/metabobank/validator.rb → ...els/database/metabobank/file_validator.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,18 @@ | ||||||
| class Database::Trad::DDBJRecordValidator | ||||||
| def validate(validation) | ||||||
| obj = validation.objs.without_base.last | ||||||
|
|
||||||
| begin | ||||||
| JSON.parse(obj.file.download) | ||||||
|
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.
Suggested change
|
||||||
|
|
||||||
| obj.validity_valid! if obj.validation_details.empty? | ||||||
| rescue JSON::ParserError => e | ||||||
| obj.validity_invalid! | ||||||
|
|
||||||
| obj.validation_details.create!( | ||||||
| severity: 'error', | ||||||
| message: e.message | ||||||
| ) | ||||||
| end | ||||||
| end | ||||||
| end | ||||||
2 changes: 1 addition & 1 deletion
2
app/models/database/trad/validator.rb → app/models/database/trad/file_validator.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
app/models/database/trad2/validator.rb → app/models/database/trad2/file_validator.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| class Database::Trad2::Validator | ||
| class Database::Trad2::FileValidator | ||
| include TradValidation | ||
|
|
||
| ASSOC = { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| { | ||
| **accession_renewal.slice( | ||
| :id, | ||
| :started_at, | ||
| :finished_at, | ||
| :progress, | ||
| :validity, | ||
| :created_at | ||
| ), | ||
|
|
||
| file: { | ||
| filename: accession_renewal.file.filename, | ||
| url: accession_renewal_file_url(accession_renewal) | ||
| }, | ||
|
|
||
| validation_details: accession_renewal.validation_details.map {|detail| | ||
| { | ||
| **detail.slice( | ||
| :severity | ||
| ), | ||
|
|
||
| message: detail.message.scrub | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| render(@renewal) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,12 @@ | ||
| # locals: (accession:) | ||
|
|
||
| accession.slice( | ||
| :number, | ||
| :entry_id, | ||
| :version, | ||
| :last_updated_at | ||
| ) | ||
| { | ||
| **accession.slice( | ||
| :number, | ||
| :entry_id, | ||
| :version, | ||
| :last_updated_at | ||
| ), | ||
|
|
||
| renewals: render(partial: 'accession_renewals/accession_renewal', collection: accession.renewals) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| class CreateAccessionRenewals < ActiveRecord::Migration[8.0] | ||
| def change | ||
| create_table :accession_renewals do |t| | ||
| t.references :accession, null: false, foreign_key: true | ||
|
|
||
| t.string :progress, null: false, default: "waiting" | ||
| t.string :validity | ||
| t.datetime :started_at | ||
| t.datetime :finished_at | ||
|
|
||
| t.timestamps | ||
| end | ||
|
|
||
| create_table :accession_renewal_validation_details do |t| | ||
| t.references :renewal, null: false, foreign_key: {to_table: :accession_renewals} | ||
|
|
||
| t.string :severity, null: false | ||
| t.string :message, null: false | ||
|
|
||
| t.timestamps | ||
| end | ||
| end | ||
| end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.