Class: RailsPerformance::Models::Record
- Inherits:
-
Object
- Object
- RailsPerformance::Models::Record
- Defined in:
- lib/rails_performance/models/record.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
-
#datetime ⇒ Object
readonly
Returns the value of attribute datetime.
-
#datetimei ⇒ Object
readonly
Returns the value of attribute datetimei.
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#request_id ⇒ Object
readonly
Returns the value of attribute request_id.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Class Method Summary collapse
Instance Method Summary collapse
- #controller_action ⇒ Object
- #controller_action_format ⇒ Object
-
#initialize(key, value) ⇒ Record
constructor
key = performance| controller|HomeController| action|index| format|html| status|200| datetime|20200124T0523| datetimei|1579861423| method|GET| path|/| request_id|454545454545454545| END = “view_runtime”:8.444603008683771,“db_runtime”:0,“duration”:9“view_runtime”:8.444603008683771,“db_runtime”:0,“duration”:9.216095000000001 value = JSON.
- #to_h ⇒ Object
- #value ⇒ Object
Constructor Details
#initialize(key, value) ⇒ Record
key = performance| controller|HomeController| action|index| format|html| status|200| datetime|20200124T0523| datetimei|1579861423| method|GET| path|/| request_id|454545454545454545| END
RailsPerformance::Models::Record.“view_runtime”:8.444603008683771,“db_runtime”:0,“duration”:9“view_runtime”:8.444603008683771,“db_runtime”:0,“duration”:9.216095000000001
value = JSON
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/rails_performance/models/record.rb', line 29 def initialize(key, value) @json = value items = key.split("|") @controller = items[2] @action = items[4] @format = items[6] @status = items[8] @datetime = items[10] @datetimei = items[12] @method = items[14] @path = items[16] @request_id = items[18] end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
4 5 6 |
# File 'lib/rails_performance/models/record.rb', line 4 def action @action end |
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
4 5 6 |
# File 'lib/rails_performance/models/record.rb', line 4 def controller @controller end |
#datetime ⇒ Object (readonly)
Returns the value of attribute datetime.
4 5 6 |
# File 'lib/rails_performance/models/record.rb', line 4 def datetime @datetime end |
#datetimei ⇒ Object (readonly)
Returns the value of attribute datetimei.
4 5 6 |
# File 'lib/rails_performance/models/record.rb', line 4 def datetimei @datetimei end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
4 5 6 |
# File 'lib/rails_performance/models/record.rb', line 4 def format @format end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
4 5 6 |
# File 'lib/rails_performance/models/record.rb', line 4 def method @method end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
4 5 6 |
# File 'lib/rails_performance/models/record.rb', line 4 def path @path end |
#request_id ⇒ Object (readonly)
Returns the value of attribute request_id.
4 5 6 |
# File 'lib/rails_performance/models/record.rb', line 4 def request_id @request_id end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
4 5 6 |
# File 'lib/rails_performance/models/record.rb', line 4 def status @status end |
Class Method Details
.find_by(request_id:) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/rails_performance/models/record.rb', line 7 def Record.find_by(request_id:) keys, values = RP::Utils.fetch_from_redis("performance|*|request_id|#{request_id}|*") return nil if keys.blank? return nil if values.blank? RP::Models::Record.new(keys[0], values[0]) end |
Instance Method Details
#controller_action ⇒ Object
49 50 51 |
# File 'lib/rails_performance/models/record.rb', line 49 def controller_action "#{controller}##{action}" end |
#controller_action_format ⇒ Object
53 54 55 |
# File 'lib/rails_performance/models/record.rb', line 53 def controller_action_format "#{controller}##{action}|#{format}" end |
#to_h ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/rails_performance/models/record.rb', line 57 def to_h { controller: controller, action: action, format: format, method: method, path: path, duration: ms(value['duration']), view_runtime: ms(value['view_runtime']), db_runtime: ms(value['db_runtime']), HTTP_REFERER: value['HTTP_REFERER'] } end |
#value ⇒ Object
45 46 47 |
# File 'lib/rails_performance/models/record.rb', line 45 def value @value ||= JSON.parse(@json || "{}") end |