mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-26 01:35:34 +08:00
Fix protocol repository save/load timestamps [SCI-5067]
This commit is contained in:
parent
3a4a166856
commit
7cd12bfb07
4 changed files with 20 additions and 14 deletions
|
@ -31,8 +31,10 @@ module ActiveStorage
|
||||||
|
|
||||||
unless processing
|
unless processing
|
||||||
ActiveStorage::PreviewJob.perform_later(@blob.id)
|
ActiveStorage::PreviewJob.perform_later(@blob.id)
|
||||||
|
ActiveRecord::Base.no_touching do
|
||||||
@blob.attachments.take.record.update(file_processing: true)
|
@blob.attachments.take.record.update(file_processing: true)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,7 +6,9 @@ class ActiveStorage::PreviewJob < ActiveStorage::BaseJob
|
||||||
|
|
||||||
discard_on StandardError do |job, error|
|
discard_on StandardError do |job, error|
|
||||||
blob = ActiveStorage::Blob.find_by(id: job.arguments.first)
|
blob = ActiveStorage::Blob.find_by(id: job.arguments.first)
|
||||||
|
ActiveRecord::Base.no_touching do
|
||||||
blob&.attachments&.take&.record&.update(file_processing: false)
|
blob&.attachments&.take&.record&.update(file_processing: false)
|
||||||
|
end
|
||||||
Rails.logger.error "Couldn't generate preview for Blob with id: #{job.arguments.first}. Error:\n #{error}"
|
Rails.logger.error "Couldn't generate preview for Blob with id: #{job.arguments.first}. Error:\n #{error}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -24,6 +26,8 @@ class ActiveStorage::PreviewJob < ActiveStorage::BaseJob
|
||||||
Rails.logger.info "Preview for the Blod with id: #{blob.id} - successfully generated.\n" \
|
Rails.logger.info "Preview for the Blod with id: #{blob.id} - successfully generated.\n" \
|
||||||
"Transformations applied: #{preview.variation.transformations}"
|
"Transformations applied: #{preview.variation.transformations}"
|
||||||
|
|
||||||
|
ActiveRecord::Base.no_touching do
|
||||||
blob.attachments.take.record.update(file_processing: false)
|
blob.attachments.take.record.update(file_processing: false)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -32,17 +32,15 @@ class Asset < ApplicationRecord
|
||||||
optional: true
|
optional: true
|
||||||
belongs_to :team, optional: true
|
belongs_to :team, optional: true
|
||||||
has_one :step_asset, inverse_of: :asset, dependent: :destroy
|
has_one :step_asset, inverse_of: :asset, dependent: :destroy
|
||||||
has_one :step, through: :step_asset, dependent: :nullify
|
has_one :step, through: :step_asset, touch: true, dependent: :nullify
|
||||||
has_one :result_asset, inverse_of: :asset, dependent: :destroy
|
has_one :result_asset, inverse_of: :asset, dependent: :destroy
|
||||||
has_one :result, through: :result_asset, dependent: :nullify
|
has_one :result, through: :result_asset, touch: true, dependent: :nullify
|
||||||
has_one :repository_asset_value, inverse_of: :asset, dependent: :destroy
|
has_one :repository_asset_value, inverse_of: :asset, dependent: :destroy
|
||||||
has_one :repository_cell, through: :repository_asset_value,
|
has_one :repository_cell, through: :repository_asset_value,
|
||||||
dependent: :nullify
|
dependent: :nullify
|
||||||
has_many :report_elements, inverse_of: :asset, dependent: :destroy
|
has_many :report_elements, inverse_of: :asset, dependent: :destroy
|
||||||
has_one :asset_text_datum, inverse_of: :asset, dependent: :destroy
|
has_one :asset_text_datum, inverse_of: :asset, dependent: :destroy
|
||||||
|
|
||||||
after_save { result&.touch; step&.touch }
|
|
||||||
|
|
||||||
attr_accessor :file_content, :file_info, :in_template
|
attr_accessor :file_content, :file_info, :in_template
|
||||||
|
|
||||||
def self.search(
|
def self.search(
|
||||||
|
|
|
@ -229,6 +229,7 @@ class Protocol < ApplicationRecord
|
||||||
|
|
||||||
# Deep-clone given array of assets
|
# Deep-clone given array of assets
|
||||||
def self.deep_clone_assets(assets_to_clone)
|
def self.deep_clone_assets(assets_to_clone)
|
||||||
|
ActiveRecord::Base.no_touching do
|
||||||
assets_to_clone.each do |src_id, dest_id|
|
assets_to_clone.each do |src_id, dest_id|
|
||||||
src = Asset.find_by(id: src_id)
|
src = Asset.find_by(id: src_id)
|
||||||
dest = Asset.find_by(id: dest_id)
|
dest = Asset.find_by(id: dest_id)
|
||||||
|
@ -239,6 +240,7 @@ class Protocol < ApplicationRecord
|
||||||
src.duplicate_file(dest)
|
src.duplicate_file(dest)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def self.clone_contents(src, dest, current_user, clone_keywords)
|
def self.clone_contents(src, dest, current_user, clone_keywords)
|
||||||
assets_to_clone = []
|
assets_to_clone = []
|
||||||
|
|
Loading…
Reference in a new issue