Sha256: 9a45e97fd45c9b63112382138ff28c40a0a6c59a01a91814d14320c0c6b11c41

Contents?: true

Size: 1.11 KB

Versions: 2

Compression:

Stored size: 1.11 KB

Contents

module RailsPerformance
  module Models
    class Record
      attr_reader :controller, :action, :format, :status, :datetime, :datetimei, :method, :path

      # key = performance|
      # controller|HomeController|
      # action|index|
      # format|html|
      # status|200|
      # datetime|20200124T0523|
      # datetimei|1579861423|
      # method|GET|
      # path|/|
      # END
      # = {"view_runtime":8.444603008683771,"db_runtime":0,"duration":9.216095000000001}
      # value = JSON
      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]
      end

      def value
        @value ||= JSON.parse(@json)
      end

      def controller_action
        "#{controller}##{action}"
      end

      def controller_action_format
        "#{controller}##{action}|#{format}"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rails_performance-0.0.1.6 lib/rails_performance/models/record.rb
rails_performance-0.0.1.5 lib/rails_performance/models/record.rb