Commit 2e279eb197cbe2acc5d3fa8af349d0dad8e283a7
1 parent
49b0fe02
Exists in
master
and in
1 other branch
added a tally of browsers on which an error occurred to err/summary
Showing
4 changed files
with
71 additions
and
2 deletions
Show diff stats
app/helpers/application_helper.rb
| 1 | 1 | module ApplicationHelper |
| 2 | + | |
| 3 | + | |
| 2 | 4 | def lighthouse_tracker? object |
| 3 | 5 | object.issue_tracker_type == "lighthouseapp" |
| 4 | 6 | end |
| 7 | + | |
| 8 | + | |
| 9 | + def user_agent_graph(error) | |
| 10 | + tallies = tally(error.notices) {|notice| pretty_user_agent(notice.user_agent)} | |
| 11 | + create_percentage_table(tallies, :total => error.notices.count) | |
| 12 | + end | |
| 13 | + | |
| 14 | + def pretty_user_agent(user_agent) | |
| 15 | + (user_agent.nil? || user_agent.none?) ? "N/A" : "#{user_agent.browser} #{user_agent.version}" | |
| 16 | + end | |
| 17 | + | |
| 18 | + | |
| 19 | + def tally(collection, &block) | |
| 20 | + collection.inject({}) do |tallies, item| | |
| 21 | + value = yield item | |
| 22 | + tallies[value] = (tallies[value] || 0) + 1 | |
| 23 | + tallies | |
| 24 | + end | |
| 25 | + end | |
| 26 | + | |
| 27 | + | |
| 28 | + def create_percentage_table(tallies, options={}) | |
| 29 | + total = (options[:total] || total_from_tallies(tallies)) | |
| 30 | + percent = 100.0 / total.to_f | |
| 31 | + rows = tallies.map {|value, count| [(count.to_f * percent), value]} \ | |
| 32 | + .sort {|a, b| a[0] <=> b[0]} | |
| 33 | + render :partial => "errs/tally_table", :locals => {:rows => rows} | |
| 34 | + end | |
| 35 | + | |
| 36 | + | |
| 37 | +private | |
| 38 | + | |
| 39 | + | |
| 40 | + def total_from_tallies(tallies) | |
| 41 | + tallies.values.inject(0) {|sum, n| sum + n} | |
| 42 | + end | |
| 43 | + | |
| 44 | + | |
| 5 | 45 | end | ... | ... |
app/views/notices/_summary.html.haml
| ... | ... | @@ -15,4 +15,7 @@ |
| 15 | 15 | %td= notice.created_at.to_s(:micro) |
| 16 | 16 | %tr |
| 17 | 17 | %th Similar |
| 18 | - %td= notice.err.notices.count - 1 | |
| 19 | 18 | \ No newline at end of file |
| 19 | + %td= notice.err.notices.count - 1 | |
| 20 | + %tr | |
| 21 | + %th Browser | |
| 22 | + %td= user_agent_graph(notice.err) | |
| 20 | 23 | \ No newline at end of file | ... | ... |
public/stylesheets/application.css
| ... | ... | @@ -562,7 +562,7 @@ table.errs td.app .environment { |
| 562 | 562 | table.errs td.message a { |
| 563 | 563 | width: 420px; |
| 564 | 564 | display: block; |
| 565 | - word-wrap: break-word; | |
| 565 | + word-wrap: break-word; | |
| 566 | 566 | } |
| 567 | 567 | table.errs td.message em { |
| 568 | 568 | color: #727272; |
| ... | ... | @@ -574,6 +574,27 @@ table.errs tr.resolved td > * { |
| 574 | 574 | -webkit-opacity: 0.5; |
| 575 | 575 | } |
| 576 | 576 | |
| 577 | +/* Tally tables */ | |
| 578 | +table.tally { | |
| 579 | + border:none; | |
| 580 | +} | |
| 581 | +table.tally td, | |
| 582 | +table.tally th { | |
| 583 | + border:none !important; | |
| 584 | + background:none !important; | |
| 585 | + padding:8px 0 0; | |
| 586 | +} | |
| 587 | +table.tally tbody tr:first-child td, | |
| 588 | +table.tally tbody tr:first-child th { | |
| 589 | + padding-top:0; | |
| 590 | +} | |
| 591 | +table.tally td.percent { | |
| 592 | + width:4.5em; | |
| 593 | +} | |
| 594 | +table.tally th.value { | |
| 595 | + text-transform:none; | |
| 596 | +} | |
| 597 | + | |
| 577 | 598 | /* Resolve Errs */ |
| 578 | 599 | #action-bar a.resolve { |
| 579 | 600 | background: transparent url(images/icons/thumbs-up.png) 6px 5px no-repeat; | ... | ... |