Viewing Statistics
Least viewed slides
<% if @least.size > 0 %>
<% max = @least.sort_by {|slide, time| -time}[0][1].to_f %>
<% timestr = (max > 3599) ? '%H:%M:%S' : '%M:%S' %>
<% @least.each do |slide, time| %>
<%= slide %>
<%= Time.at(time).gmtime.strftime(timestr) %>
<% end %>
<% end %>
Most viewed slides
<% if @least.size > 0 %>
<% max = @most[0][1].to_f %>
<% timestr = (max > 3599) ? '%H:%M:%S' : '%M:%S' %>
<% @most.each do |slide, time| %>
<%= slide %>
<%= Time.at(time).gmtime.strftime(timestr) %>
<% end %>
<% end %>
All slides
<%# We reuse the max value calculated from the above step. %>
<% @all.sort.map do |slide, time| %>
<%= slide %>
<%= Time.at(time).gmtime.strftime(timestr) %>
<% if @counter %>
<% @counter[slide].each do |host, count| %>
<%= host %>:
<%= Time.at(count).gmtime.strftime(timestr) %>
<% end %>
<% end %>
<% end %>