Sha256: 93be182c65d52e6cdce1983dc6455dfa98c3d0c369946e864d138a3f81f9046a

Contents?: true

Size: 918 Bytes

Versions: 52

Compression:

Stored size: 918 Bytes

Contents

# frozen_string_literal: true

require_dependency "renalware/letters"

module Renalware
  module Letters
    class Batch < ApplicationRecord
      include Accountable

      # TODO: I think these attributes are dead
      attr_accessor(
        :url,
        :enclosures_present,
        :state_eq,
        :author_id_eq,
        :created_by_id_eq,
        :letterhead_id_eq,
        :page_count_in_array,
        :s
      )

      enum status: { queued: 0, processing: 10, awaiting_printing: 15, failure: 20, success: 30 }
      has_many(
        :items,
        dependent: :restrict_with_exception,
        class_name: "Renalware::Letters::BatchItem"
      )
      has_many(
        :letters,
        through: :items,
        class_name: "Renalware::Letters::Letter"
      )

      def percent_complete
        ((items.where(status: :compiled).count.to_f / batch_items_count) * 100).ceil
      end
    end
  end
end

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
renalware-core-2.0.167 app/models/renalware/letters/batch.rb
renalware-core-2.0.166 app/models/renalware/letters/batch.rb
renalware-core-2.0.165 app/models/renalware/letters/batch.rb
renalware-core-2.0.164 app/models/renalware/letters/batch.rb
renalware-core-2.0.163 app/models/renalware/letters/batch.rb
renalware-core-2.0.162 app/models/renalware/letters/batch.rb
renalware-core-2.0.161 app/models/renalware/letters/batch.rb
renalware-core-2.0.160 app/models/renalware/letters/batch.rb
renalware-core-2.0.159 app/models/renalware/letters/batch.rb
renalware-core-2.0.158 app/models/renalware/letters/batch.rb
renalware-core-2.0.157 app/models/renalware/letters/batch.rb
renalware-core-2.0.156 app/models/renalware/letters/batch.rb
renalware-core-2.0.155 app/models/renalware/letters/batch.rb
renalware-core-2.0.153 app/models/renalware/letters/batch.rb
renalware-core-2.0.152 app/models/renalware/letters/batch.rb
renalware-core-2.0.151 app/models/renalware/letters/batch.rb
renalware-core-2.0.149 app/models/renalware/letters/batch.rb
renalware-core-2.0.148 app/models/renalware/letters/batch.rb
renalware-core-2.0.147 app/models/renalware/letters/batch.rb
renalware-core-2.0.146 app/models/renalware/letters/batch.rb