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.
11 12 13 |
# File 'app/models/spotlight/reindex_progress.rb', line 11 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.
7 8 9 |
# File 'app/models/spotlight/reindex_progress.rb', line 7 def current_log_entry @current_log_entry end |
Instance Method Details
#as_json ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/models/spotlight/reindex_progress.rb', line 45 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
37 38 39 |
# File 'app/models/spotlight/reindex_progress.rb', line 37 def completed current_log_entry.items_reindexed_count end |
#errored? ⇒ Boolean
41 42 43 |
# File 'app/models/spotlight/reindex_progress.rb', line 41 def errored? current_log_entry.failed? end |
#finished? ⇒ Boolean
25 26 27 |
# File 'app/models/spotlight/reindex_progress.rb', line 25 def finished? current_log_entry.succeeded? || current_log_entry.failed? end |
#finished_at ⇒ Object
29 30 31 |
# File 'app/models/spotlight/reindex_progress.rb', line 29 def finished_at current_log_entry.end_time end |
#recently_in_progress? ⇒ Boolean
15 16 17 18 19 |
# File 'app/models/spotlight/reindex_progress.rb', line 15 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
21 22 23 |
# File 'app/models/spotlight/reindex_progress.rb', line 21 def started_at current_log_entry.start_time end |
#total ⇒ Object
33 34 35 |
# File 'app/models/spotlight/reindex_progress.rb', line 33 def total current_log_entry.items_reindexed_estimate end |