Skip to content
Browse files

add last-solved-date

  • Loading branch information...
1 parent ad8253c commit 1c7cab34ab792a66522a7977954fe1ee2737a86f @gigasquid gigasquid committed Jun 4, 2011
Showing with 12 additions and 2 deletions.
  1. +2 −1 project.clj
  2. +3 −1 src/foreclojure/problems.clj
  3. +7 −0 test/foreclojure/test/users.clj
View
3 project.clj
@@ -16,6 +16,7 @@
[incanter/incanter-charts "1.2.3"]
[org.apache.commons/commons-email "1.2"]]
:dev-dependencies [[lein-ring "0.4.0"]
- [swank-clojure "1.2.1"]]
+ [swank-clojure "1.2.1"]
+ [midje "1.1.1"]]
:main foreclojure.core
:ring {:handler foreclojure.core/app})
View
4 src/foreclojure/problems.clj
@@ -95,10 +95,12 @@
(defn store-completed-state! [username problem-id code]
(let [{user-id :_id} (fetch-one :users
:where {:user username}
- :only [:_id])]
+ :only [:_id])
+ current-time (java.util.Date.)]
(when (not-any? #{problem-id} (get-solved username))
(update! :users {:_id user-id} {:$addToSet {:solved problem-id}})
(update! :problems {:_id problem-id} {:$inc {:times-solved 1}})
+ (update! :users {:_id problem-id} {:$set {:last-solved-date current-time}})
@amalloy
4clojure member
amalloy added a note Aug 13, 2011

@gigasquid, this line doesn't make sense. Is last-solved-date supposed to be on a user or a problem?

It also looks like last-solved-date isn't used anywhere, so I'm not sure why we're storing it. If it's part of a feature you're planning to finish it might have been better to have this on a branch until it was ready, but I don't mind leaving it in. If you don't think we need it anymore, let me know and I'll rip it out.

@gigasquid
4clojure member
gigasquid added a note Aug 13, 2011

Ah, it was tied to the sorting request for https://github.com/dbyrne/4clojure/issues/47

I think my initial idea was to use the last-solved-date - but after talking with David it made more sense to use last-login-date. It seems like I left it in by mistake. Actually, I need to rework the test too. I think I remember that I came up with my own sort function and ran it by you and found it that it could be replaced with a one line juxt ;)
(def sort-by-solved-and-date (juxt (comp count :solved) :last-login))

I'll take a look at fixing my test for users.clj so that it makes sense now. Please rip out the other stuff too not needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
(send total-solved inc))
(record-golf-score! user-id problem-id (code-length code))
(save-solution (? user-id) (? problem-id) (? code))))
View
7 test/foreclojure/test/users.clj
@@ -0,0 +1,7 @@
+(ns foreclojure.test.users
+ (:use [foreclojure.users] :reload)
+ (:use [clojure.test])
+ (:use [midje.sweet]))
+
+(deftest "sorting users by solved/ contributer/ solved-date/ username"
+ (fact))

0 comments on commit 1c7cab3

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