Skip to content

Fix filtering for following column on all-users page. Issue #202. #228

Merged
merged 2 commits into from Sep 4, 2012

2 participants

@nbeloglazov

No description provided.

@amalloy amalloy commented on an outdated diff Sep 4, 2012
src/foreclojure/users.clj
@@ -249,8 +249,13 @@
(defn datatable-paging [start length users]
(take length (drop start users)))
-(let [column-sorts [:rank :user (comp count :solved)]]
- (defn datatable-sort-cols [sort-col users]
+(defn get-sort-by-following-fn []
+ (let [following (if-user [{:keys [following]}]
+ (set following))]
@amalloy
4clojure member
amalloy added a note Sep 4, 2012

Indentation under if-user is wrong here. Should line up like an if.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@amalloy amalloy commented on an outdated diff Sep 4, 2012
src/foreclojure/users.clj
@@ -249,8 +249,13 @@
(defn datatable-paging [start length users]
(take length (drop start users)))
-(let [column-sorts [:rank :user (comp count :solved)]]
- (defn datatable-sort-cols [sort-col users]
+(defn get-sort-by-following-fn []
+ (let [following (if-user [{:keys [following]}]
+ (set following))]
+ #(if (following (:_id %)) -1 1)))
@amalloy
4clojure member
amalloy added a note Sep 4, 2012

I don't really like the lambda syntax here. I think it reads better as a fn form so that the param (and optionally the function itself) can get a descriptive name to clarify what's going on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@amalloy amalloy commented on an outdated diff Sep 4, 2012
src/foreclojure/users.clj
@@ -249,8 +249,13 @@
(defn datatable-paging [start length users]
(take length (drop start users)))
-(let [column-sorts [:rank :user (comp count :solved)]]
- (defn datatable-sort-cols [sort-col users]
+(defn get-sort-by-following-fn []
@amalloy
4clojure member
amalloy added a note Sep 4, 2012

I think I'd just name this sort-by-following. And please add a comment explaining why this thing that "looks" like a constant needs to be a nullary function - it depends on the mutable state for if-user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@amalloy amalloy merged commit 9063385 into 4clojure:develop Sep 4, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.