Class: Spotlight::ReindexProgress
- Inherits:
-
Object
- Object
- Spotlight::ReindexProgress
- Defined in:
- app/models/spotlight/reindex_progress.rb
Overview
ReindexProgress is a class that models the progress of reindexing a list of resources
Instance Attribute Summary collapse
-
#exhibit ⇒ Object
readonly
Returns the value of attribute exhibit.
Instance Method Summary collapse
- #as_json ⇒ Object
- #completed ⇒ Object
- #errored? ⇒ Boolean
- #finished? ⇒ Boolean
- #finished_at ⇒ Object
-
#initialize(exhibit) ⇒ ReindexProgress
constructor
A new instance of ReindexProgress.
- #recently_in_progress? ⇒ Boolean
- #started_at ⇒ Object
- #total ⇒ Object
- #updated_at ⇒ Object
Constructor Details
#initialize(exhibit) ⇒ ReindexProgress
Returns a new instance of ReindexProgress.
7 8 9 |
# File 'app/models/spotlight/reindex_progress.rb', line 7 def initialize(exhibit) @exhibit = exhibit end |
Instance Attribute Details
#exhibit ⇒ Object (readonly)
Returns the value of attribute exhibit.
5 6 7 |
# File 'app/models/spotlight/reindex_progress.rb', line 5 def exhibit @exhibit end |
Instance Method Details
#as_json ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/models/spotlight/reindex_progress.rb', line 48 def as_json(*) { recently_in_progress: recently_in_progress?, started_at: localized_start_time, finished_at: localized_finish_time, updated_at: localized_updated_time, total: total, completed: completed, errored: errored? } end |
#completed ⇒ Object
39 40 41 |
# File 'app/models/spotlight/reindex_progress.rb', line 39 def completed current_log_entry.try(:items_reindexed_count) end |
#errored? ⇒ Boolean
43 44 45 46 |
# File 'app/models/spotlight/reindex_progress.rb', line 43 def errored? return false if current_log_entry.blank? current_log_entry.failed? end |
#finished? ⇒ Boolean
26 27 28 29 |
# File 'app/models/spotlight/reindex_progress.rb', line 26 def finished? return false if current_log_entry.blank? current_log_entry.succeeded? || current_log_entry.failed? end |
#finished_at ⇒ Object
31 32 33 |
# File 'app/models/spotlight/reindex_progress.rb', line 31 def finished_at current_log_entry.try(:end_time) end |
#recently_in_progress? ⇒ Boolean
11 12 13 14 15 16 |
# File 'app/models/spotlight/reindex_progress.rb', line 11 def recently_in_progress? return false if current_log_entry.blank? return true if current_log_entry.in_progress? current_log_entry.end_time.present? && (current_log_entry.end_time > Spotlight::Engine.config.reindex_progress_window.minutes.ago) end |
#started_at ⇒ Object
18 19 20 |
# File 'app/models/spotlight/reindex_progress.rb', line 18 def started_at current_log_entry.try(:start_time) end |
#total ⇒ Object
35 36 37 |
# File 'app/models/spotlight/reindex_progress.rb', line 35 def total current_log_entry.try(:items_reindexed_estimate) end |
#updated_at ⇒ Object
22 23 24 |
# File 'app/models/spotlight/reindex_progress.rb', line 22 def updated_at current_log_entry.try(:updated_at) end |