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