Module: Railscope::DashboardHelper
- Defined in:
- app/helpers/railscope/dashboard_helper.rb
Instance Method Summary collapse
- #entry_title(entry) ⇒ Object
- #render_entry_summary(entry) ⇒ Object
- #render_json(hash, indent: 0) ⇒ Object
- #render_json_value(value, indent: 0) ⇒ Object
- #timeline_summary(entry) ⇒ Object
Instance Method Details
#entry_title(entry) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/helpers/railscope/dashboard_helper.rb', line 5 def entry_title(entry) case entry.entry_type when "request" "#{entry.payload["method"]} #{entry.payload["path"]}" when "query" entry.payload["name"] || entry.payload["sql"].to_s.truncate(50) when "exception" entry.payload["class"] when "job_enqueue", "job_perform" entry.payload["job_class"] else entry.entry_type.titleize end end |
#render_entry_summary(entry) ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'app/helpers/railscope/dashboard_helper.rb', line 90 def render_entry_summary(entry) case entry.entry_type when "request" render_request_summary(entry.payload) when "query" render_query_summary(entry.payload) when "exception" render_exception_summary(entry.payload) when "job_enqueue", "job_perform" render_job_summary(entry.payload) else entry.payload.to_json.truncate(100) end end |
#render_json(hash, indent: 0) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/helpers/railscope/dashboard_helper.rb', line 35 def render_json(hash, indent: 0) return content_tag(:span, "null", class: "json-null") if hash.nil? content_tag(:div, class: "json-object") do safe_join(hash.map do |key, value| content_tag(:div, class: "json-row", style: "padding-left: #{indent * 16}px") do key_tag = content_tag(:span, "#{key}:", class: "json-key") value_tag = render_json_value(value, indent: indent) safe_join([key_tag, value_tag], " ") end end) end end |
#render_json_value(value, indent: 0) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'app/helpers/railscope/dashboard_helper.rb', line 49 def render_json_value(value, indent: 0) case value when nil content_tag(:span, "null", class: "json-null") when true, false content_tag(:span, value.to_s, class: "json-boolean") when Numeric content_tag(:span, value.to_s, class: "json-number") when String if value.length > 100 content_tag(:span, class: "json-string long") do content_tag(:code, value) end else content_tag(:span, "\"#{value}\"", class: "json-string") end when Array if value.empty? content_tag(:span, "[]", class: "json-array-empty") else content_tag(:div, class: "json-array") do safe_join([ content_tag(:span, "[", class: "json-bracket"), content_tag(:div, class: "json-array-items") do safe_join(value.map { |v| render_json_value(v, indent: indent + 1) }) end, content_tag(:span, "]", class: "json-bracket") ]) end end when Hash if value.empty? content_tag(:span, "{}", class: "json-object-empty") else render_json(value, indent: indent + 1) end else content_tag(:span, value.to_s, class: "json-string") end end |
#timeline_summary(entry) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/helpers/railscope/dashboard_helper.rb', line 20 def timeline_summary(entry) case entry.entry_type when "request" "#{entry.payload["method"]} #{entry.payload["path"]}" when "query" entry.payload["sql"].to_s.truncate(40) when "exception" entry.payload["class"] when "job_enqueue", "job_perform" entry.payload["job_class"] else entry.entry_type end end |