Class: PgHero::HomeController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- PgHero::HomeController
- Defined in:
- app/controllers/pg_hero/home_controller.rb
Instance Method Summary collapse
- #enable_query_stats ⇒ Object
- #explain ⇒ Object
- #index ⇒ Object
- #indexes ⇒ Object
- #kill ⇒ Object
- #kill_all ⇒ Object
- #queries ⇒ Object
- #query_stats ⇒ Object
- #reset_query_stats ⇒ Object
- #space ⇒ Object
- #system_stats ⇒ Object
Instance Method Details
#enable_query_stats ⇒ Object
77 78 79 80 81 82 83 84 |
# File 'app/controllers/pg_hero/home_controller.rb', line 77 def enable_query_stats begin PgHero.enable_query_stats redirect_to :back, notice: "Query stats enabled" rescue ActiveRecord::StatementInvalid => e redirect_to :back, alert: "The database user does not have permission to enable query stats" end end |
#explain ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'app/controllers/pg_hero/home_controller.rb', line 50 def explain @title = "Explain" @query = params[:query] # TODO use get + token instead of post so users can share links # need to prevent CSRF and DoS if request.post? and @query begin @explanation = PgHero.explain(@query) rescue ActiveRecord::StatementInvalid => e @error = e. end end end |
#index ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/controllers/pg_hero/home_controller.rb', line 11 def index @title = "Status" @slow_queries = PgHero.slow_queries @long_running_queries = PgHero.long_running_queries @index_hit_rate = PgHero.index_hit_rate @table_hit_rate = PgHero.table_hit_rate @missing_indexes = PgHero.missing_indexes @unused_indexes = PgHero.unused_indexes @good_cache_rate = @table_hit_rate >= 0.99 && @index_hit_rate >= 0.99 @query_stats_available = PgHero.query_stats_available? @rds = PgHero.rds? end |
#indexes ⇒ Object
24 25 26 27 |
# File 'app/controllers/pg_hero/home_controller.rb', line 24 def indexes @title = "Indexes" @index_usage = PgHero.index_usage end |
#kill ⇒ Object
64 65 66 67 68 69 70 |
# File 'app/controllers/pg_hero/home_controller.rb', line 64 def kill if PgHero.kill(params[:pid]) redirect_to root_path, notice: "Query killed" else redirect_to :back, notice: "Query no longer running" end end |
#kill_all ⇒ Object
72 73 74 75 |
# File 'app/controllers/pg_hero/home_controller.rb', line 72 def kill_all PgHero.kill_all redirect_to :back, notice: "Connections killed" end |
#queries ⇒ Object
35 36 37 38 |
# File 'app/controllers/pg_hero/home_controller.rb', line 35 def queries @title = "Live Queries" @running_queries = PgHero.running_queries end |
#query_stats ⇒ Object
40 41 42 43 |
# File 'app/controllers/pg_hero/home_controller.rb', line 40 def query_stats @title = "Queries" @query_stats = PgHero.query_stats end |
#reset_query_stats ⇒ Object
86 87 88 89 90 91 92 93 |
# File 'app/controllers/pg_hero/home_controller.rb', line 86 def reset_query_stats begin PgHero.reset_query_stats redirect_to :back, notice: "Query stats reset" rescue ActiveRecord::StatementInvalid => e redirect_to :back, alert: "The database user does not have permission to reset query stats" end end |
#space ⇒ Object
29 30 31 32 33 |
# File 'app/controllers/pg_hero/home_controller.rb', line 29 def space @title = "Space" @database_size = PgHero.database_size @relation_sizes = PgHero.relation_sizes end |