Class: Result
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Result
- Defined in:
- app/models/result.rb
Instance Method Summary collapse
- #copy_latest_result ⇒ Object
- #current_result_filename ⇒ Object
- #current_result_s3_key ⇒ Object
- #enqueue_duration ⇒ Object
- #mark_complete_with_count(row_count) ⇒ Object
- #mark_failed!(message) ⇒ Object
- #mark_processing_from_sample(result_sample) ⇒ Object
- #mark_running! ⇒ Object
- #redis_result_row_count ⇒ Object
- #row_count ⇒ Object
- #run_duration ⇒ Object
Instance Method Details
#copy_latest_result ⇒ Object
50 51 52 53 54 |
# File 'app/models/result.rb', line 50 def copy_latest_result if AwsS3.s3_enabled? && query.present? && query.scheduled_flag AwsS3.copy(current_result_s3_key, query.latest_result_key) end end |
#current_result_filename ⇒ Object
56 57 58 |
# File 'app/models/result.rb', line 56 def current_result_filename @result_filename ||= CsvHelper::Base.new(id).filename end |
#current_result_s3_key ⇒ Object
60 61 62 |
# File 'app/models/result.rb', line 60 def current_result_s3_key @result_key ||= CsvHelper::Aws.new(id).key end |
#enqueue_duration ⇒ Object
46 47 48 |
# File 'app/models/result.rb', line 46 def enqueue_duration duration(:created_at, :started_at) end |
#mark_complete_with_count(row_count) ⇒ Object
25 26 27 28 |
# File 'app/models/result.rb', line 25 def mark_complete_with_count(row_count) update_attributes!(status: 'complete', row_count: row_count, completed_at: Time.now) copy_latest_result end |
#mark_failed!(message) ⇒ Object
30 31 32 |
# File 'app/models/result.rb', line 30 def mark_failed!() update_attributes!(status: 'failed', error_message: , completed_at: Time.now) end |
#mark_processing_from_sample(result_sample) ⇒ Object
21 22 23 |
# File 'app/models/result.rb', line 21 def mark_processing_from_sample(result_sample) update_attributes!(status: 'processing', sample_data: result_sample) end |
#mark_running! ⇒ Object
17 18 19 |
# File 'app/models/result.rb', line 17 def mark_running! update_attributes!(status: 'running', started_at: Time.now) end |
#redis_result_row_count ⇒ Object
38 39 40 |
# File 'app/models/result.rb', line 38 def redis_result_row_count @redis_result_row_count ||= RedisResultRowCount.new(self) end |
#row_count ⇒ Object
34 35 36 |
# File 'app/models/result.rb', line 34 def row_count super || ongoing_row_count end |
#run_duration ⇒ Object
42 43 44 |
# File 'app/models/result.rb', line 42 def run_duration duration(:started_at, :completed_at) end |