Class: Spotlight::BackgroundJobProgress

Inherits:
Object
  • Object
show all
Defined in:
app/models/spotlight/background_job_progress.rb

Overview

BackgroundJobProgress is a class that models the progress of a list of resources

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(exhibit, job_class:) ⇒ BackgroundJobProgress

Returns a new instance of BackgroundJobProgress.



11
12
13
14
# File 'app/models/spotlight/background_job_progress.rb', line 11

def initialize(exhibit, job_class:)
  @exhibit = exhibit
  @job_class = job_class
end

Instance Attribute Details

#exhibitObject (readonly)

Returns the value of attribute exhibit.



7
8
9
# File 'app/models/spotlight/background_job_progress.rb', line 7

def exhibit
  @exhibit
end

#job_classObject (readonly)

Returns the value of attribute job_class.



7
8
9
# File 'app/models/spotlight/background_job_progress.rb', line 7

def job_class
  @job_class
end

Instance Method Details

#as_jsonObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/models/spotlight/background_job_progress.rb', line 16

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].max,
    completed:,
    finished: finished?,
    errored: errored?
  }
end