Analyze PDF only if present
This commit is contained in:
@@ -13,8 +13,8 @@ class Job < ApplicationRecord
|
|||||||
validates_presence_of :pdf, unless: :created_by_operator?
|
validates_presence_of :pdf, unless: :created_by_operator?
|
||||||
validates :privacy_policy, acceptance: true, unless: :created_by_operator?
|
validates :privacy_policy, acceptance: true, unless: :created_by_operator?
|
||||||
validates :number_of_plans_a0, :number_of_plans_a1, :number_of_plans_a2, :number_of_plans_a3, :costum_qm_plan, numericality: { greater_than_or_equal_to: 0 }
|
validates :number_of_plans_a0, :number_of_plans_a1, :number_of_plans_a2, :number_of_plans_a3, :costum_qm_plan, numericality: { greater_than_or_equal_to: 0 }
|
||||||
|
validate :acceptable_pdf, unless: :created_by_operator?
|
||||||
|
|
||||||
validate :acceptable_pdf
|
|
||||||
|
|
||||||
before_save :update_status_changed_at, if: :will_save_change_to_status?
|
before_save :update_status_changed_at, if: :will_save_change_to_status?
|
||||||
before_save :update_user_status_infos, if: -> { will_save_change_to_status? || new_record? }
|
before_save :update_user_status_infos, if: -> { will_save_change_to_status? || new_record? }
|
||||||
@@ -173,15 +173,17 @@ class Job < ApplicationRecord
|
|||||||
# TODO: add any check if attachment has changed
|
# TODO: add any check if attachment has changed
|
||||||
|
|
||||||
# pdfs.each do |pdf|
|
# pdfs.each do |pdf|
|
||||||
pdf.blob.open do |file|
|
if pdf.blob
|
||||||
# file = ActiveStorage::Blob.service.path_for(pdf.key).to_s
|
pdf.blob.open do |file|
|
||||||
pdf_analyzer = Services::PdfAnalyzer.new(file)
|
# file = ActiveStorage::Blob.service.path_for(pdf.key).to_s
|
||||||
pdf_analyzer.analyze
|
pdf_analyzer = Services::PdfAnalyzer.new(file)
|
||||||
self.number_of_plans_a0 += pdf_analyzer.pages_a0
|
pdf_analyzer.analyze
|
||||||
self.number_of_plans_a1 += pdf_analyzer.pages_a1
|
self.number_of_plans_a0 += pdf_analyzer.pages_a0
|
||||||
self.number_of_plans_a2 += pdf_analyzer.pages_a2
|
self.number_of_plans_a1 += pdf_analyzer.pages_a1
|
||||||
self.number_of_plans_a3 += pdf_analyzer.pages_a3
|
self.number_of_plans_a2 += pdf_analyzer.pages_a2
|
||||||
self.costum_qm_plan += pdf_analyzer.costum_qm
|
self.number_of_plans_a3 += pdf_analyzer.pages_a3
|
||||||
|
self.costum_qm_plan += pdf_analyzer.costum_qm
|
||||||
|
end
|
||||||
end
|
end
|
||||||
# end
|
# end
|
||||||
calc_cost
|
calc_cost
|
||||||
|
|||||||
Reference in New Issue
Block a user