                      get-pace
                      tags])))
 
-(def ex-filter 
-  {:creationDate {"$gte" (time/date-time 2013 1 1)}})
+(defn ex-filter [year user]
+  {"$and" [{:creationDate {"$gte" (time/date-time year 1 1)}} {:creationDate {"$lt" (time/date-time (inc year) 1 1)}} {:user user}]})
 
 (defn to-csv [exs] 
   (str

  (mq/with-collection EXERCISE 
    (mq/find query)
    (mq/sort {:creationDate 1})
    (mq/batch-size 5000)))

(defn csv-escape [field]
  (let [s (str field)]

(defn export [params]
  (.info logger (str "Exporting csv " params))
  (if-let [user (:user params)]
    (let [year (if (:year params) (Integer/valueOf (:year params)) (time/year (time/now)))]
      (to-csv (exs (ex-filter year user))))
    ""))
