def tally_results(current_stats, stat_name, total_stats)
        current_stats.each do |stats|
          # Exclude the stats from today since it will only be a partial day's worth of data
          break if stats.date == Time.zone.today

          date_key = stats.date.to_s
          old_count = total_stats[date_key] ? total_stats[date_key].fetch(stat_name) { 0 } : 0
          new_count = old_count + stats.method(stat_name).call

          old_values = total_stats[date_key] || {}
          total_stats.store(date_key, old_values)
          total_stats[date_key].store(stat_name, new_count)
        end
        total_stats
      end
def tally_results(current_stats, stat_name, total_stats)
        current_stats.each do |stats|
          # Exclude the stats from today since it will only be a partial day's worth of data
          break if stats.date == Time.zone.today

          date_key = stats.date.to_s
          old_count = total_stats[date_key] ? total_stats[date_key].fetch(stat_name) { 0 } : 0
          new_count = old_count + stats.method(stat_name).call

          old_values = total_stats[date_key] || {}
          total_stats.store(date_key, old_values)
          total_stats[date_key].store(stat_name, new_count)
        end
        total_stats
      end
For each date, add the view and download counts for this file to the view & download sub-totals for that day.
 The resulting hash will look something like this: {"2014-11-30 00:00:00 UTC" => {:views=>2, :downloads=>5},
 "2014-12-01 00:00:00 UTC" => {:views=>4, :downloads=>4}}