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
-
#current_log_entry ⇒ Object
readonly
Returns the value of attribute current_log_entry.
Instance Method Summary collapse
- #as_json ⇒ Object
- #completed ⇒ Object
- #errored? ⇒ Boolean
- #finished? ⇒ Boolean
- #finished_at ⇒ Object
-
#initialize(current_log_entry) ⇒ ReindexProgress
constructor
A new instance of ReindexProgress.
- #recently_in_progress? ⇒ Boolean
- #started_at ⇒ Object
- #total ⇒ Object
Constructor Details
#initialize(current_log_entry) ⇒ ReindexProgress
Returns a new instance of ReindexProgress.
9 10 11 |
# File 'app/models/spotlight/reindex_progress.rb', line 9 def initialize(current_log_entry) @current_log_entry = current_log_entry end |
Instance Attribute Details
#current_log_entry ⇒ Object (readonly)
Returns the value of attribute current_log_entry.
5 6 7 |
# File 'app/models/spotlight/reindex_progress.rb', line 5 def current_log_entry @current_log_entry end |
Instance Method Details
#as_json ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/models/spotlight/reindex_progress.rb', line 43 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, finished: finished?, errored: errored? } end |
#completed ⇒ Object
35 36 37 |
# File 'app/models/spotlight/reindex_progress.rb', line 35 def completed current_log_entry.items_reindexed_count end |
#errored? ⇒ Boolean
39 40 41 |
# File 'app/models/spotlight/reindex_progress.rb', line 39 def errored? current_log_entry.failed? end |
#finished? ⇒ Boolean
23 24 25 |
# File 'app/models/spotlight/reindex_progress.rb', line 23 def finished? current_log_entry.succeeded? || current_log_entry.failed? end |
#finished_at ⇒ Object
27 28 29 |
# File 'app/models/spotlight/reindex_progress.rb', line 27 def finished_at current_log_entry.end_time end |
#recently_in_progress? ⇒ Boolean
13 14 15 16 17 |
# File 'app/models/spotlight/reindex_progress.rb', line 13 def recently_in_progress? 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
19 20 21 |
# File 'app/models/spotlight/reindex_progress.rb', line 19 def started_at current_log_entry.start_time end |
#total ⇒ Object
31 32 33 |
# File 'app/models/spotlight/reindex_progress.rb', line 31 def total current_log_entry.items_reindexed_estimate end |