Sha256: 268e81e2d81c355822ba3b32baf7989f7e0d8a4f3287ecc662d566d74e34a187

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

module RailsMiniProfiler
  class ProfiledRequestPresenter < BasePresenter
    def request_name
      model.request_path
    end

    def duration
      formatted_duration(model.duration)
    end

    def allocations
      formatted_allocations(model.allocations)
    end

    def created_at
      time_tag(model.created_at.in_time_zone(Time.zone))
    end

    def flamegraph_icon
      return nil unless RailsMiniProfiler.configuration.flamegraph_enabled

      if model.flamegraph.present?
        link_to(flamegraph_path(model.id), title: 'Show Flamegraph') do
          inline_svg('graph.svg')
        end
      else
        link_to(flamegraph_path(model.id), title: 'No Flamegraph present for this request', class: 'link-disabled') do
          inline_svg('graph.svg')
        end
      end
    end

    def flamegraph_button
      return nil unless RailsMiniProfiler.configuration.flamegraph_enabled

      return nil unless model.flamegraph.present?

      link_to(flamegraph_path(model.id), title: 'Show Flamegraph', class: 'flamegraph-button') do
        content_tag('button', 'Flamegraph')
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rails_mini_profiler-0.4.0 app/presenters/rails_mini_profiler/profiled_request_presenter.rb
rails_mini_profiler-0.3.0 app/presenters/rails_mini_profiler/profiled_request_presenter.rb