Permalink
Browse files

Add "of out total" to the ranking

  • Loading branch information...
gigasquid committed Sep 15, 2011
1 parent 015a8f6 commit cfd7276404826365f401a5e65d600854a2ecf9b1
Showing with 7 additions and 6 deletions.
  1. +3 −2 src/foreclojure/users.clj
  2. +4 −4 test/foreclojure/test/users.clj
@@ -30,9 +30,10 @@
(sort-by sortfn users)))
(defn get-user-with-ranking [username, users]
- (let [users-with-rankings (map-indexed
+ (let [total (count users)
+ users-with-rankings (map-indexed
(fn [idx itm]
- (assoc itm :rank (inc idx))) users) ]
+ (assoc itm :rank (str (inc idx) " out of " total))) users) ]
(first
(filter #(= username (% :user)) users-with-rankings))))
@@ -38,8 +38,8 @@
(facts "about user"
- (:rank (get-user-with-ranking "user1" users)) => 1
- (:rank (get-user-with-ranking "user2" users)) => 2
- (:rank (get-user-with-ranking "user3" users)) => 3
- (:rank (get-user-with-ranking "user4" users)) => 4 ))
+ (:rank (get-user-with-ranking "user1" users)) => "1 out of 4"
+ (:rank (get-user-with-ranking "user2" users)) => "2 out of 4"
+ (:rank (get-user-with-ranking "user3" users)) => "3 out of 4"
+ (:rank (get-user-with-ranking "user4" users)) => "4 out of 4" ))

0 comments on commit cfd7276

Please sign in to comment.