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

      (update-in [:num-grans] #(+ % (:num-grans i2)))
      (assoc :end (:end i2))))

(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."
