Class: Report
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Report
- Includes:
- Stateflow
- Defined in:
- app/models/report.rb
Instance Method Summary collapse
- #build? ⇒ Boolean
- #decode_field(field) ⇒ Object
- #enqueue! ⇒ Object
- #report_builder ⇒ Object
-
#title ⇒ Object
METHODS.
Instance Method Details
#build? ⇒ Boolean
59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'app/models/report.rb', line 59 def build? query = report_builder.query begin data = ActiveRecord::Base.connection.exec_query(query).to_hash ReportResult.create! :report_id => id, :rows => data.length, :data => data return :done rescue Exception => e update_attribute :error, e.to_s return :error end end |
#decode_field(field) ⇒ Object
72 73 74 75 |
# File 'app/models/report.rb', line 72 def decode_field(field) raise "Incorrect field '#{field}' given" unless field.starts_with?('_') report_template.fields[field[1..-1].to_i] end |
#enqueue! ⇒ Object
21 22 23 24 25 |
# File 'app/models/report.rb', line 21 def enqueue! enqueue save! ReportWorker.perform_async(id) end |
#report_builder ⇒ Object
54 55 56 57 |
# File 'app/models/report.rb', line 54 def report_builder return nil if report_template.blank? @report_builder ||= report_template.report_builder(self) end |
#title ⇒ Object
METHODS
50 51 52 |
# File 'app/models/report.rb', line 50 def title "##{id} (#{report_template.title})" end |