Sha256: 63a9c18614c5a8bbac9c20207bd0512f71beb8ef9a4383a67b94f9550ef78241

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literals: true

module Jobshop
  class Inspection::Report < ApplicationRecord
    self.primary_keys = %i[ organization_id report_id ]

    after_initialize { self.report_id ||= SecureRandom.uuid if new_record? }

    belongs_to :organization, inverse_of: :inspection_reports

    has_many :criteria, -> { includes(:criterion).order(:position) },
      foreign_key: %i[ organization_id report_id ], inverse_of: :report

    has_many :limit_criteria, inverse_of: :report,
      foreign_key: %i[ organization_id report_id ]

    has_many :tuples, -> { order(:position) },  inverse_of: :report,
      foreign_key: %i[ organization_id report_id ]

=begin
    def ascii
      require "terminal-table"
      table = Terminal::Table.new do |t|
        t.title = "Inspection Report"
        t << [ "Feature" ].concat(criteria.map(&:criterion).map(&:name))
        t << [ "Specification" ].concat(criteria.map(&:criterion).map(&:specification))
        tuples.each do |tuple|
          results = criteria.map do |criterion|
            tuple.results.find_by(criterion: criterion)
          end
          t << [ tuple.position ].concat(results.map(&:value))
        end
      end

      puts table
    end
=end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jobshop-0.0.167 app/models/jobshop/inspection/report.rb