Sha256: 0eccc16dede109bab01231541529be3f563bb6ad17b812bb5f507c634119673f

Contents?: true

Size: 804 Bytes

Versions: 8

Compression:

Stored size: 804 Bytes

Contents

module Speedos
  class Record
    include Mongoid::Document
    include Mongoid::Timestamps

    field :success, type: Boolean
    field :log

    scope :successful, ->() { where(success: true) }

    def entries
      self.log['entries']
    end

    def pages
      self.log['pages'].reject{ |p| p['id'].empty? }.map{ |p| page(p['id']) }
    end

    def page name
      Entries.new(entries.select{ |p| p["pageref"] == name })
    end

    def export_har filename
      File.open(filename, 'w') { |f| f.write({log: self.log}.to_json)}
    end

    def self.report
      Record.successful.all.each do |record|
        puts record.id
        record.pages.each do |page|
          puts "  %-30s %ss" % [page.all_names.first, (page.total_load_time / 1000).round(5)]
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
speedos-0.0.11 lib/speedos/models/record.rb
speedos-0.0.10 lib/speedos/models/record.rb
speedos-0.0.9 lib/speedos/models/record.rb
speedos-0.0.8 lib/speedos/models/record.rb
speedos-0.0.7 lib/speedos/models/record.rb
speedos-0.0.6 lib/speedos/models/record.rb
speedos-0.0.5 lib/speedos/models/record.rb
speedos-0.0.4 lib/speedos/models/record.rb