2 def prepare_heatmap(data, from, to)
3 # Pad the start by one week to ensure the heatmap can start on the first day of the week
4 all_days = ((from - 1.week).to_date..to.to_date).map do |date|
5 data[date] || { :date => date, :total_changes => 0 }
8 # Get unique months with repeating months and count into the next year with numbers over 12
10 months = ((from - 2.weeks).to_date..(to + 1.week).to_date)
12 .chunk_while { |before, after| before == after }
15 month_offset += 12 if month == 1
22 :max_per_day => data.values.pluck(:total_changes).max