Class: RailsMemoryProfiler::ReportsController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- BaseController
- RailsMemoryProfiler::ReportsController
- Defined in:
- app/controllers/rails_memory_profiler/reports_controller.rb
Constant Summary collapse
- SORTABLE_COLUMNS =
%w[path controller allocated_objects retained_objects duration_ms recorded_at].freeze
Instance Method Summary collapse
Instance Method Details
#clear ⇒ Object
18 19 20 21 |
# File 'app/controllers/rails_memory_profiler/reports_controller.rb', line 18 def clear ReportStore.clear redirect_to reports_path end |
#index ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'app/controllers/rails_memory_profiler/reports_controller.rb', line 5 def index reports = ReportStore.all respond_to do |format| format.json { render json: reports } format.html do @sort = SORTABLE_COLUMNS.include?(params[:sort]) ? params[:sort] : "recorded_at" @direction = params[:direction] == "asc" ? "asc" : "desc" @reports = sorted(reports, @sort, @direction) end end end |
#show ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/controllers/rails_memory_profiler/reports_controller.rb', line 23 def show @report = ReportStore.find(params[:id]) respond_to do |format| format.html format.json do if @report render json: @report else render json: { error: "Report not found" }, status: :not_found end end end end |