Skip to content

Commit

Permalink
add last-solved-date
Browse files Browse the repository at this point in the history
  • Loading branch information
gigasquid committed Jun 5, 2011
1 parent ad8253c commit 1c7cab3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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})
4 changes: 3 additions & 1 deletion src/foreclojure/problems.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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}})
(send total-solved inc))
(record-golf-score! user-id problem-id (code-length code))
(save-solution (? user-id) (? problem-id) (? code))))
Expand Down
7 changes: 7 additions & 0 deletions test/foreclojure/test/users.clj
Original file line number Diff line number Diff line change
@@ -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.