Class: RailsPerformance::Models::RakeRecord
- Inherits:
-
BaseRecord
- Object
- BaseRecord
- RailsPerformance::Models::RakeRecord
- Defined in:
- lib/rails_performance/models/rake_record.rb
Instance Attribute Summary collapse
-
#datetime ⇒ Object
Returns the value of attribute datetime.
-
#datetimei ⇒ Object
Returns the value of attribute datetimei.
-
#duration ⇒ Object
Returns the value of attribute duration.
-
#status ⇒ Object
Returns the value of attribute status.
-
#task ⇒ Object
Returns the value of attribute task.
Class Method Summary collapse
-
.from_db(key, value) ⇒ Object
rake|task||datetime|20210416T1254|datetimei|1618602843|status|error|END|1.0.0 “duration”:0“duration”:0.00012442.
Instance Method Summary collapse
-
#initialize(task:, duration: nil, datetime:, datetimei:, status:, json: '{}') ⇒ RakeRecord
constructor
A new instance of RakeRecord.
- #record_hash ⇒ Object
- #save ⇒ Object
Methods inherited from BaseRecord
Constructor Details
#initialize(task:, duration: nil, datetime:, datetimei:, status:, json: '{}') ⇒ RakeRecord
Returns a new instance of RakeRecord.
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rails_performance/models/rake_record.rb', line 20 def initialize(task:, duration: nil, datetime:, datetimei:, status:, json: '{}') @task = Array.wrap(task) @datetime = datetime @datetimei = datetimei.to_i @status = status @duration = duration @json = json @duration ||= value['duration'] end |
Instance Attribute Details
#datetime ⇒ Object
Returns the value of attribute datetime.
4 5 6 |
# File 'lib/rails_performance/models/rake_record.rb', line 4 def datetime @datetime end |
#datetimei ⇒ Object
Returns the value of attribute datetimei.
4 5 6 |
# File 'lib/rails_performance/models/rake_record.rb', line 4 def datetimei @datetimei end |
#duration ⇒ Object
Returns the value of attribute duration.
4 5 6 |
# File 'lib/rails_performance/models/rake_record.rb', line 4 def duration @duration end |
#status ⇒ Object
Returns the value of attribute status.
4 5 6 |
# File 'lib/rails_performance/models/rake_record.rb', line 4 def status @status end |
#task ⇒ Object
Returns the value of attribute task.
4 5 6 |
# File 'lib/rails_performance/models/rake_record.rb', line 4 def task @task end |
Class Method Details
.from_db(key, value) ⇒ Object
rake|task||datetime|20210416T1254|datetimei|1618602843|status|error|END|1.0.0 “duration”:0“duration”:0.00012442
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/rails_performance/models/rake_record.rb', line 8 def RakeRecord.from_db(key, value) items = key.split("|") RakeRecord.new( task: JSON.parse(items[2]), datetime: items[4], datetimei: items[6], status: items[8], json: value ) end |
Instance Method Details
#record_hash ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/rails_performance/models/rake_record.rb', line 31 def record_hash { task: task, datetime: Time.at(datetimei), datetimei: datetimei, duration: duration, status: status, } end |
#save ⇒ Object
41 42 43 44 45 |
# File 'lib/rails_performance/models/rake_record.rb', line 41 def save key = "rake|task|#{task.to_json}|datetime|#{datetime}|datetimei|#{datetimei}|status|#{status}|END|#{RailsPerformance::SCHEMA}" value = { duration: duration } Utils.save_to_redis(key, value) end |