                                    [(conj new-intervals prev) current])]
         (recur (rest intervals) new-intervals prev)))))
 
-(def interval-granularity->period-fn
+(def ^:private interval-granularity->period-fn
   "Maps interval granularity types to the clj-time period functions"
   {:year t/years
    :month t/months

   :second t/seconds})


(defn advance-interval-end-date
  "Advances the interval end date by one unit of interval granularity. The end dates coming back from
  elasticsearch are at the beginning of the interval. The granules end date falls somewhere between
  the start of the interval and the end of it. By advancing the end date to the end we indicate to

  (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]
