Class: RailsPerformance::Models::JobRecord

Inherits:
BaseRecord
  • Object
show all
Defined in:
lib/rails_performance/models/job_record.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseRecord

#duration, #value

Constructor Details

#initialize(key, value) ⇒ JobRecord

key = job-performance |queue|default |worker|SimpleWorker |jid|7d48fbf20976c224510dbc60 |datetime|20200124T0523 |created_ati|1583146613 |enqueued_ati|1583146613 |start_timei|1583146614 |status|success|END value = JSON



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/rails_performance/models/job_record.rb', line 16

def initialize(key, value)
  @json = value

  items = key.split("|")

  @queue        = items[2]
  @worker       = items[4]
  @jid          = items[6]
  @datetime     = items[8]
  @created_ati  = items[10]
  @enqueued_ati = items[12]
  @start_timei  = items[14]
  @status       = items[16]
end

Instance Attribute Details

#created_atiObject (readonly)

Returns the value of attribute created_ati.



4
5
6
# File 'lib/rails_performance/models/job_record.rb', line 4

def created_ati
  @created_ati
end

#datetimeObject (readonly)

Returns the value of attribute datetime.



4
5
6
# File 'lib/rails_performance/models/job_record.rb', line 4

def datetime
  @datetime
end

#enqueued_atiObject (readonly)

Returns the value of attribute enqueued_ati.



4
5
6
# File 'lib/rails_performance/models/job_record.rb', line 4

def enqueued_ati
  @enqueued_ati
end

#jidObject (readonly)

Returns the value of attribute jid.



4
5
6
# File 'lib/rails_performance/models/job_record.rb', line 4

def jid
  @jid
end

#queueObject (readonly)

Returns the value of attribute queue.



4
5
6
# File 'lib/rails_performance/models/job_record.rb', line 4

def queue
  @queue
end

#start_timeiObject (readonly)

Returns the value of attribute start_timei.



4
5
6
# File 'lib/rails_performance/models/job_record.rb', line 4

def start_timei
  @start_timei
end

#statusObject (readonly)

Returns the value of attribute status.



4
5
6
# File 'lib/rails_performance/models/job_record.rb', line 4

def status
  @status
end

#workerObject (readonly)

Returns the value of attribute worker.



4
5
6
# File 'lib/rails_performance/models/job_record.rb', line 4

def worker
  @worker
end

Instance Method Details

#to_hObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/rails_performance/models/job_record.rb', line 31

def to_h
  {
    queue: queue,
    worker: worker,
    jid: jid,
    datetime: datetime,
    created_ati: created_ati,
    enqueued_ati: enqueued_ati,
    start_timei: start_timei,
    duration: duration,
    status: status,
    message: value['message']
  }
end