From bbac5e0ea48d2e443da6c9901ff09c11e8010f83 Mon Sep 17 00:00:00 2001 From: Scott Ostler Date: Sat, 8 Jan 2011 17:03:16 -0500 Subject: fetch-dumps-by-ids doesn't crash when given empty id list --- src/tags.clj | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/tags.clj b/src/tags.clj index 53236c5..fb530ea 100644 --- a/src/tags.clj +++ b/src/tags.clj @@ -332,21 +332,22 @@ WHERE EXISTS (defn fetch-dumps-by-ids ([ids] (fetch-dumps-by-ids ids nil)) ([ids viewer-nick] - (let [ids (map maybe-parse-int ids) - query (fetch-dumps-by-message-id-query :num-messages (count ids)) - raw-rows (do-select (vec (concat [query] ids))) - tagged-rows (map parse-tags-from-row-as-tag-map raw-rows) - index-func (fn [row] - (index-of #(= (:message_id row) %) ids))] - (for [m (sort-by index-func tagged-rows)] - (let [favers (get (:tags m) "favorite") - favorited (and viewer-nick - (boolean (some #(= % viewer-nick) favers))) - filtered-favers (filter #(not= % (:nick m)) favers)] - (assoc m - :favers filtered-favers - :favorited favorited - :count (count filtered-favers))))))) + (if-not (empty? ids) + (let [ids (map maybe-parse-int ids) + query (fetch-dumps-by-message-id-query :num-messages (count ids)) + raw-rows (do-select (vec (concat [query] ids))) + tagged-rows (map parse-tags-from-row-as-tag-map raw-rows) + index-func (fn [row] + (index-of #(= (:message_id row) %) ids))] + (for [m (sort-by index-func tagged-rows)] + (let [favers (get (:tags m) "favorite") + favorited (and viewer-nick + (boolean (some #(= % viewer-nick) favers))) + filtered-favers (filter #(not= % (:nick m)) favers)] + (assoc m + :favers filtered-favers + :favorited favorited + :count (count filtered-favers)))))))) (defn fetch-dump-by-id ([m-id] -- cgit v1.2.3-70-g09d2 From 482d439f6e8f024848a873772b0758645514a077 Mon Sep 17 00:00:00 2001 From: dumpfmprod Date: Sat, 8 Jan 2011 17:04:06 -0500 Subject: sostler prod commit --- template/mini_profile.st | 1 + template/popular.st | 2 +- template/rooms/VIP.st | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/template/mini_profile.st b/template/mini_profile.st index a991f6b..90b1689 100644 --- a/template/mini_profile.st +++ b/template/mini_profile.st @@ -20,6 +20,7 @@
dumps
dumps faved
+
top dumps

contact info

$if(contact)$ diff --git a/template/popular.st b/template/popular.st index c900dd9..162c63b 100644 --- a/template/popular.st +++ b/template/popular.st @@ -4,7 +4,7 @@ $head()$ diff --git a/template/rooms/VIP.st b/template/rooms/VIP.st index fa38eb5..9ade34c 100644 --- a/template/rooms/VIP.st +++ b/template/rooms/VIP.st @@ -10,7 +10,7 @@ \ \:\/:/ \ \:\ /:/ \ \:\ \ \::/ \ \::/ \ \:\ \ \::/ \ \:\/:/ \ \:\ \ \:\ \ \:\ \ \:\ \__\/ \ \::/ \ \:\ \ \:\ \ \:\ \ \:\ - \__\/ \__\/ \__\/ \__\/ \__\/ + \__\/ \__\/ \__\/ \__\/ \__\/ (c)2010 dump.fm --> @@ -140,8 +140,8 @@

Welcome to the cool club

-- cgit v1.2.3-70-g09d2