Class: ImageQualityCheck::Result

Inherits:
ApplicationRecord
  • Object
show all
Defined in:
lib/image_quality_check/model.rb

Overview

Schema Information

Table name: image_quality_check_results

id                :bigint(8)        not null, primary key
attachable_column :string(255)
attachable_type   :string(255)
quality           :integer
result            :json
created_at        :datetime         not null
updated_at        :datetime         not null
attachable_id     :string(255)

Indexes

index_image_quality_checks_on_all         (attachable_type,attachable_id,attachable_column) UNIQUE
index_image_quality_checks_on_attachable  (attachable_type,attachable_id)

Class Method Summary collapse

Class Method Details

.create_for_result(attachable, column, result) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/image_quality_check/model.rb', line 25

def self.create_for_result(attachable, column, result)
  check = ImageQualityCheck::Result.where(attachable: attachable, attachable_column: column).first_or_initialize
  check.quality = result[:quality]
  check.result = {
    details: result[:details],
    messages: result[:messages],
  }
  check.save!
end