Skip to content
Browse files

Improvements due to comments in pull request.

  • Loading branch information...
1 parent 51ef71d commit ec8cc3b871431242a97145a70725ba7c21026c8d @nbeloglazov nbeloglazov committed Sep 4, 2012
Showing with 8 additions and 4 deletions.
  1. +8 −4 src/foreclojure/users.clj
12 src/foreclojure/users.clj
@@ -249,13 +249,17 @@
(defn datatable-paging [start length users]
(take length (drop start users)))
-(defn get-sort-by-following-fn []
+(defn sort-by-following
+ "Get function for sorting by following for current user.
+ We need nullary function to create sort function because 'following' set depends on current user."
+ []
(let [following (if-user [{:keys [following]}]
- (set following))]
- #(if (following (:_id %)) -1 1)))
+ (set following))]
+ (fn [user]
+ (if (contains? following (:_id user)) -1 1))))
(defn datatable-sort-cols [sort-col users]
- (let [column-sorts [:rank :user (comp count :solved) (get-sort-by-following-fn)]]
+ (let [column-sorts [:rank :user (comp count :solved) (sort-by-following)]]
(if-let [sort-fn (get column-sorts sort-col)]
(sort-by sort-fn users)

0 comments on commit ec8cc3b

Please sign in to comment.
Something went wrong with that request. Please try again.