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

        (update-in [:start] #(if (t/before? % start-date) start-date %))
        (update-in [:end] #(if (or no-end (nil? %) (t/after? % end-date)) end-date %)))))

(defn collection-bucket->intervals
  "Takes a single collection bucket from the aggregation response and returns the intervals
  for that collection."
  [interval-granularity start-date end-date collection-bucket]

   :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
