 	(:require 	[clj-time.format :as format]
 				[clojure.string :as string]
 			  	[clj-time.core :as time]))
+
+(def #^{:private true} logger (org.slf4j.LoggerFactory/getLogger (str *ns*)))
 
 (def multi-parser (format/formatter (time/default-time-zone)
                                     "dd.MM.yyyy"

                                    "yyyy"))

(defn parse-date [val] (format/parse multi-parser val))

(defn conv-fun [sport-key]
	(if (sport-key #{:distance :duration})

(defn make-basic-query [query-keys]
	(vec (map (partial apply or-filter) query-keys)))

(defn long-cmp-keys[]
	(vec (for [op ["lte" "gte" "lt" "gt"] qkey ["pace" "distance" "duration" "avghr"]]
		(keyword (str op "_" qkey)))))

(defn make-query-from [params]
  (let [basic-query (make-basic-query (select-keys params [:user :tags :sport :distance :duration]))
  		date-range-query (make-range-query parse-date (select-keys params [:lte_creationDate :gte_creationDate]))
  		long-range-query (make-range-query parse-long (select-keys params (long-cmp-keys)))]
  	{$and (vec (concat basic-query date-range-query long-range-query))}))

(defn sortby [params]
	(if-let [sortkey (:sb params)]
