about summary refs log tree commit diff
path: root/config/initializers
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-11-22 22:59:54 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-11-22 22:59:54 +0100
commitfc90d38893ae81b83884c3f5c85d05d564f1de33 (patch)
tree8d881992a6afe8519277e6206c6289f574c00337 /config/initializers
parent4b5b953d4223776860bcccb56d2f9c7144dc302e (diff)
Moving some counter queries out of subqueries in the API
Diffstat (limited to 'config/initializers')
-rw-r--r--config/initializers/mini_profiler.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/config/initializers/mini_profiler.rb b/config/initializers/mini_profiler.rb
new file mode 100644
index 000000000..265783618
--- /dev/null
+++ b/config/initializers/mini_profiler.rb
@@ -0,0 +1,17 @@
+require 'rack-mini-profiler'
+
+Rack::MiniProfilerRails.initialize!(Rails.application)
+
+Rails.application.middleware.swap(Rack::Deflater, Rack::MiniProfiler)
+Rails.application.middleware.swap(Rack::MiniProfiler, Rack::Deflater)
+
+Rack::MiniProfiler.config.storage = Rack::MiniProfiler::MemoryStore
+
+if Rails.env.production?
+  Rack::MiniProfiler.config.storage_options = {
+    host: ENV.fetch('REDIS_HOST') { 'localhost' },
+    port: ENV.fetch('REDIS_PORT') { 6379 },
+  }
+
+  Rack::MiniProfiler.config.storage = Rack::MiniProfiler::RedisStore
+end