 
 (defn add-recent-images [db]
   (assoc db :recent (take 5 (:images db))))
-
-(defn init []
-  (load-data-from-disk)
-  (assert-fs))

  (sql-exists? (sql-user-exists db email)))

(defn users-exist? []
  (sql-exists? (sql-user-count db-spec)))

(defn like-exists? [db image user]
  (sql-exists? (sql-like-exists db image user)))

(defn add-user-to-db [user & admin]
  (let [admin (if (and (seq admin) (first admin))
            true
            (if (users-exist?)
              false
              true))]
    (with-db-transaction [connection db-spec]
      (when-not (user-exists? connection (:email user))
        (sql-insert-user! connection
                          (hash-bcrypt (:password user))


(defn get-images [& limit]
  (let [images (if (seq limit)
                  (sql-get-images-limit (get-db-spec) (first limit))
                  (sql-get-all-images (get-db-spec)))]
    (map beef-up-image images)))

(defn get-image-by-id 
  ([id] (get-image-by-id id 0))
  ([id user-id]
   (when-let [images (sql-get-image-by-id (get-db-spec) user-id id)]
      (beef-up-image (first images)))))

(defn add-image-to-db [image user-id]
  (sql-insert-image! (get-db-spec)
                     (:filename image)
                     (:caption image)
                     (:focal-length image)
