Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Karma leaderboard should not including scores of 0 or less #779

Merged
merged 2 commits into from Nov 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion project.clj
Expand Up @@ -24,7 +24,7 @@
:timeout 120000
:welcome (println "Welcome to the yetibot development REPL!")}
:dependencies [[org.clojure/clojure "1.9.0"]
[yetibot.core "0.4.52"]
[yetibot.core "0.4.53"]

; apis
[twitter-api "1.8.0"]
Expand Down
1 change: 1 addition & 0 deletions src/yetibot/models/karma.clj
Expand Up @@ -30,6 +30,7 @@
[]
(db/query {:select/clause "user_id, SUM(points) as score"
:group/clause "user_id"
:having/clause "SUM(points) > 0"
:order/clause "score DESC"
:limit/clause 10}))

Expand Down
7 changes: 6 additions & 1 deletion test/yetibot/test/models/karma.clj
Expand Up @@ -42,4 +42,9 @@

(fact "get-high-scores returns at least one item"
(add-score-delta! test-user test-voter 1 nil)
(-> (get-high-scores) count (>= 1)) => truthy))
(-> (get-high-scores) count (>= 1)) => truthy)

(fact "get-high-scores should not includes scores of 0 or less"
(add-score-delta! test-user test-voter 1 nil)
(add-score-delta! test-user test-voter -1 nil)
(->> (get-high-scores) (filter #(= (:user-id %) test-user)) count) => 0))