Class: RailsPerformance::Models::DelayedJobRecord
- Inherits:
-
BaseRecord
- Object
- BaseRecord
- RailsPerformance::Models::DelayedJobRecord
- Defined in:
- lib/rails_performance/models/delayed_job_record.rb
Instance Attribute Summary collapse
-
#class_name ⇒ Object
Returns the value of attribute class_name.
-
#datetime ⇒ Object
Returns the value of attribute datetime.
-
#datetimei ⇒ Object
Returns the value of attribute datetimei.
-
#duration ⇒ Object
Returns the value of attribute duration.
-
#jid ⇒ Object
Returns the value of attribute jid.
-
#json ⇒ Object
Returns the value of attribute json.
-
#method_name ⇒ Object
Returns the value of attribute method_name.
-
#source_type ⇒ Object
Returns the value of attribute source_type.
-
#status ⇒ Object
Returns the value of attribute status.
Class Method Summary collapse
-
.from_db(key, value) ⇒ Object
delayed_job |jid|22 |datetime|20210415T0616 |datetimei|1618492591 |source_type|instance_method |class_name|User |method_name|say_hello_without_delay |status|success|END|1.0.0.
Instance Method Summary collapse
-
#initialize(jid:, duration: nil, datetime:, datetimei:, source_type:, class_name:, method_name:, status:, json: '{}') ⇒ DelayedJobRecord
constructor
A new instance of DelayedJobRecord.
- #record_hash ⇒ Object
- #save ⇒ Object
Methods inherited from BaseRecord
Constructor Details
#initialize(jid:, duration: nil, datetime:, datetimei:, source_type:, class_name:, method_name:, status:, json: '{}') ⇒ DelayedJobRecord
Returns a new instance of DelayedJobRecord.
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rails_performance/models/delayed_job_record.rb', line 29 def initialize(jid:, duration: nil, datetime:, datetimei:, source_type:, class_name:, method_name:, status:, json: '{}') @jid = jid @duration = duration @datetime = datetime @datetimei = datetimei.to_i @source_type = source_type @class_name = class_name @method_name = method_name @status = status @json = json end |
Instance Attribute Details
#class_name ⇒ Object
Returns the value of attribute class_name.
4 5 6 |
# File 'lib/rails_performance/models/delayed_job_record.rb', line 4 def class_name @class_name end |
#datetime ⇒ Object
Returns the value of attribute datetime.
4 5 6 |
# File 'lib/rails_performance/models/delayed_job_record.rb', line 4 def datetime @datetime end |
#datetimei ⇒ Object
Returns the value of attribute datetimei.
4 5 6 |
# File 'lib/rails_performance/models/delayed_job_record.rb', line 4 def datetimei @datetimei end |
#duration ⇒ Object
Returns the value of attribute duration.
4 5 6 |
# File 'lib/rails_performance/models/delayed_job_record.rb', line 4 def duration @duration end |
#jid ⇒ Object
Returns the value of attribute jid.
4 5 6 |
# File 'lib/rails_performance/models/delayed_job_record.rb', line 4 def jid @jid end |
#json ⇒ Object
Returns the value of attribute json.
4 5 6 |
# File 'lib/rails_performance/models/delayed_job_record.rb', line 4 def json @json end |
#method_name ⇒ Object
Returns the value of attribute method_name.
4 5 6 |
# File 'lib/rails_performance/models/delayed_job_record.rb', line 4 def method_name @method_name end |
#source_type ⇒ Object
Returns the value of attribute source_type.
4 5 6 |
# File 'lib/rails_performance/models/delayed_job_record.rb', line 4 def source_type @source_type end |
#status ⇒ Object
Returns the value of attribute status.
4 5 6 |
# File 'lib/rails_performance/models/delayed_job_record.rb', line 4 def status @status end |
Class Method Details
.from_db(key, value) ⇒ Object
delayed_job |jid|22 |datetime|20210415T0616 |datetimei|1618492591 |source_type|instance_method |class_name|User |method_name|say_hello_without_delay |status|success|END|1.0.0
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rails_performance/models/delayed_job_record.rb', line 14 def DelayedJobRecord.from_db(key, value) items = key.split("|") DelayedJobRecord.new( jid: items[2], datetime: items[4], datetimei: items[6], source_type: items[8], class_name: items[10], method_name: items[12], status: items[14], json: value ) end |
Instance Method Details
#record_hash ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/rails_performance/models/delayed_job_record.rb', line 41 def record_hash { jid: jid, datetime: Time.at(datetimei), datetimei: datetimei, duration: value['duration'], status: status, source_type: source_type, class_name: class_name, method_name: method_name, } end |
#save ⇒ Object
54 55 56 57 58 |
# File 'lib/rails_performance/models/delayed_job_record.rb', line 54 def save key = "delayed_job|jid|#{jid}|datetime|#{datetime}|datetimei|#{datetimei}|source_type|#{source_type}|class_name|#{class_name}|method_name|#{method_name}|status|#{status}|END|#{RailsPerformance::SCHEMA}" value = { duration: duration } Utils.save_to_redis(key, value) end |