fix for trying to retrieve ascii art under a name which returns none

This commit is contained in:
Gered 2014-04-06 17:06:39 -04:00
parent df0f6d7429
commit 01eb85c7dc

View file

@ -56,10 +56,12 @@
(throw (new IndexOutOfBoundsException)))))
(defn get-random-ascii-art [name]
(->> (couch/get-view-with-db (db-library) "list" "ids" {:key name})
(rand-nth)
:value
(get-ascii-art)))
(let [results (couch/get-view-with-db (db-library) "list" "ids" {:key name})]
(if (seq results)
(->> results
(rand-nth)
:value
(get-ascii-art)))))
(defn get-art-count []
(->> (couch/get-view-with-db (db-library) "list" "count")