Commit fb03e5a1739c9d6c1b238862b21657e99b3e5294

Authored by Nathan Broadbent
1 parent 42a2543f
Exists in master and in 1 other branch production

Tidied whitespace & indentation

Showing 1 changed file with 13 additions and 24 deletions   Show diff stats
app/helpers/application_helper.rb
1 1 module ApplicationHelper
2   -
3   -
4   -
5 2 def message_graph(problem)
6 3 create_percentage_table_for(problem) {|notice| notice.message}
7 4 end
8   -
9   -
10   -
  5 +
11 6 def user_agent_graph(problem)
12 7 create_percentage_table_for(problem) {|notice| pretty_user_agent(notice.user_agent)}
13 8 end
14   -
  9 +
15 10 def pretty_user_agent(user_agent)
16 11 (user_agent.nil? || user_agent.none?) ? "N/A" : "#{user_agent.browser} #{user_agent.version}"
17 12 end
18   -
19   -
20   -
  13 +
21 14 def tenant_graph(problem)
22 15 create_percentage_table_for(problem) {|notice| get_host(notice.request['url'])}
23 16 end
24   -
  17 +
25 18 def get_host(url)
26 19 begin
27 20 uri = url && URI.parse(url)
... ... @@ -30,14 +23,13 @@ module ApplicationHelper
30 23 "N/A"
31 24 end
32 25 end
33   -
34   -
35   -
  26 +
  27 +
36 28 def create_percentage_table_for(problem, &block)
37 29 tallies = tally(problem.notices, &block)
38 30 create_percentage_table_from_tallies(tallies, :total => problem.notices.count)
39 31 end
40   -
  32 +
41 33 def tally(collection, &block)
42 34 collection.inject({}) do |tallies, item|
43 35 value = yield item
... ... @@ -45,7 +37,7 @@ module ApplicationHelper
45 37 tallies
46 38 end
47 39 end
48   -
  40 +
49 41 def create_percentage_table_from_tallies(tallies, options={})
50 42 total = (options[:total] || total_from_tallies(tallies))
51 43 percent = 100.0 / total.to_f
... ... @@ -53,13 +45,10 @@ module ApplicationHelper
53 45 .sort {|a, b| a[0] <=> b[0]}
54 46 render :partial => "errs/tally_table", :locals => {:rows => rows}
55 47 end
56   -
57   -
58   - def total_from_tallies(tallies)
59   - tallies.values.inject(0) {|sum, n| sum + n}
60   - end
61   - private :total_from_tallies
62   -
63   -
  48 +
  49 + private
  50 + def total_from_tallies(tallies)
  51 + tallies.values.inject(0) {|sum, n| sum + n}
  52 + end
64 53 end
65 54  
... ...