Module: PgHero::HomeHelper
- Defined in:
- app/helpers/pg_hero/home_helper.rb
Instance Method Summary collapse
- #pghero_formatted_date_time(time) ⇒ Object
- #pghero_formatted_vacuum_times(time) ⇒ Object
- #pghero_js_value(value) ⇒ Object
- #pghero_pretty_ident(table, schema: nil) ⇒ Object
- #pghero_remove_index(query) ⇒ Object
Instance Method Details
#pghero_formatted_date_time(time) ⇒ Object
36 37 38 |
# File 'app/helpers/pg_hero/home_helper.rb', line 36 def pghero_formatted_date_time(time) l time.in_time_zone(@time_zone), format: :long end |
#pghero_formatted_vacuum_times(time) ⇒ Object
30 31 32 33 34 |
# File 'app/helpers/pg_hero/home_helper.rb', line 30 def pghero_formatted_vacuum_times(time) content_tag(:span, title: pghero_formatted_date_time(time)) do "#{time_ago_in_words(time, include_seconds: true).sub(/(over|about|almost) /, "").sub("less than", "<")} ago" end end |
#pghero_js_value(value) ⇒ Object
15 16 17 |
# File 'app/helpers/pg_hero/home_helper.rb', line 15 def pghero_js_value(value) json_escape(value.to_json(root: false)).html_safe end |
#pghero_pretty_ident(table, schema: nil) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 |
# File 'app/helpers/pg_hero/home_helper.rb', line 3 def pghero_pretty_ident(table, schema: nil) ident = table if schema && schema != "public" ident = "#{schema}.#{table}" end if /\A[a-z0-9_]+\z/.match?(ident) ident else @database.quote_ident(ident) end end |
#pghero_remove_index(query) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'app/helpers/pg_hero/home_helper.rb', line 19 def pghero_remove_index(query) if query[:columns] columns = query[:columns].map(&:to_sym) columns = columns.first if columns.size == 1 end ret = String.new("remove_index #{query[:table].to_sym.inspect}") ret << ", name: #{(query[:name] || query[:index]).to_s.inspect}" ret << ", column: #{columns.inspect}" if columns ret end |