From d63f7a75e98519a74297cce38ac7f8f54f7f1527 Mon Sep 17 00:00:00 2001 From: f Date: Mon, 11 May 2020 18:56:42 -0300 Subject: [PATCH] rack-mini-profiler --- Gemfile | 8 ++++++-- Gemfile.lock | 6 ++++++ app/controllers/application_controller.rb | 6 ++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 19d83467..8afdd1a8 100644 --- a/Gemfile +++ b/Gemfile @@ -70,6 +70,12 @@ gem 'validates_hostname' gem 'webpacker' gem 'yaml_db', git: 'https://0xacab.org/sutty/yaml_db.git' +# performance +gem 'flamegraph' +gem 'memory_profiler' +gem 'rack-mini-profiler' +gem 'stackprof' + group :themes do gem 'editorial-autogestiva-jekyll-theme', require: false gem 'minima', require: false @@ -87,7 +93,6 @@ group :development, :test do gem 'capybara', '~> 2.13' gem 'selenium-webdriver' gem 'sqlite3' - gem 'stackprof' end group :development do @@ -106,4 +111,3 @@ group :test do gem 'factory_bot_rails' gem 'timecop' end - diff --git a/Gemfile.lock b/Gemfile.lock index 6abb27d0..e720f393 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -158,6 +158,7 @@ GEM factory_bot (~> 5.1.0) railties (>= 4.2.0) ffi (1.12.2) + flamegraph (0.9.5) forwardable-extended (2.6.0) friendly_id (5.3.0) activerecord (>= 4.0.0) @@ -289,6 +290,8 @@ GEM pundit (2.1.0) activesupport (>= 3.0.0) rack (2.2.2) + rack-mini-profiler (2.0.1) + rack (>= 1.2.0) rack-proxy (0.6.5) rack rack-test (1.1.0) @@ -472,6 +475,7 @@ DEPENDENCIES email_address exception_notification factory_bot_rails + flamegraph friendly_id haml-lint hamlit-rails @@ -484,6 +488,7 @@ DEPENDENCIES letter_opener listen (>= 3.0.5, < 3.2) lograge + memory_profiler mini_magick minima mobility @@ -491,6 +496,7 @@ DEPENDENCIES pry puma pundit + rack-mini-profiler rails (~> 6) rails-i18n rails_warden diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 63e0077c..59ea10fc 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -9,6 +9,12 @@ class ApplicationController < ActionController::Base before_action :configure_permitted_parameters, if: :devise_controller? before_action :set_locale + before_action do + if current_usuarie.try(:ends_with?, '@' + ENV.fetch('SUTTY', 'sutty.nl')) + Rack::MiniProfiler.authorize_request + end + end + # No tenemos índice de sutty, vamos directamente a ver el listado de # sitios def index