 (defn get-tags [exercise]
   (html/text (nth exercise 8)))
 
-(defn insert [uid exercise]
+(defn insert [login-id exercise]
   (mc/insert "exercise"
                   {:date (get-timestamp exercise),
-                   :user uid,
-                   :sport 1,
+                   :user login-id,
+                   :sport (get-or-create-sport exercise),
                    :duration (get-duration exercise),
                    :distance (get-distance exercise),
                    :avghr (get-avghr exercise),

    (.getTime (java.util.Date. (- (nth date-array 2) 1900) 
                               (+ 1 (second date-array)) 
                               (first date-array) 12 0))))
(defn get-uid [name] 1)

(defn get-timestamp [exercise]
  (convert-to-timestamp (html/text (nth exercise 0))))

(defn get-heading [exercise] (html/text (nth exercise 1)))

(defn get-report [exercise] 
  "Emits the html in report and joins all strings in it."

                   :tags (get-tags exercise)
                   }))

(defn import-user-and-file [login-id filename]
  (let [login-id (get-or-create-login-id login-id)
        imported-html (import-html filename)]
    (try
      (doall
       (map #(if (is-ex? %)
               (insert login-id (get-exercise %))
               -1)
            (get-exercises imported-html)))
      (catch Exception e (prn e)))))

(defn -main [& args]
  "First arg is an username, and the second export filename."
  (import-user-and-file (first args) (second args)))
