diff --git a/src/toascii/models/db.clj b/src/toascii/models/db.clj index 346ae6e..b5819de 100644 --- a/src/toascii/models/db.clj +++ b/src/toascii/models/db.clj @@ -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")