       (update-in [:num-grans] #(+ % (:num-grans i2)))
       (assoc :end (:end i2))))
 
-(defn merge-adjacent-intervals
+(defn- merge-adjacent-intervals
   "Takes an interval-granularity and a list of intervals. Merges the intervals together that are
   within one interval granularity from each other. ASsumes intervals are already sorted by start
   date."

  (let [dist-fn (interval-granularity->dist-fn interval-granularity)]
    (= 1 (dist-fn (t/interval (:end i1) (:start i2))))))

(defn merge-intervals
  "Merges two intervals together. The start date of the first is taken along with the end date of
  the second. The hits are added together."
  [i1 i2]

  (let [one-unit ((interval-granularity->period-fn interval-granularity) 1)]
    (update-in interval [:end] #(when % (t/plus % one-unit)))))

(defn- constrain-interval-to-user-range
  "Constrains the start and end date of the interval to within the range given by the user"
  [start-date end-date interval]
  ;; This flag indicates in the ordered-events->intervals function that the interval had extra
