Skip to content

Commit ec69e68

Browse files
authored
Merge pull request #507 from danthe1st/qotw-leaderboard-fix
move QOTW points check after summation
2 parents 9f85534 + aebc8ad commit ec69e68

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/main/java/net/discordjug/javabot/systems/qotw/dao/QuestionPointsRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public List<QOTWAccount> sortByPoints(LocalDate startDate) throws DataAccessExce
9898
* @throws DataAccessException If an error occurs.
9999
*/
100100
public List<QOTWAccount> getTopAccounts(LocalDate startDate, int page, int size) throws DataAccessException {
101-
return jdbcTemplate.query("SELECT user_id, SUM(points) FROM qotw_points WHERE obtained_at >= ? AND points > 0 GROUP BY user_id ORDER BY SUM(points) DESC, user_id ASC LIMIT ? OFFSET ?",
101+
return jdbcTemplate.query("SELECT user_id, SUM(points) FROM qotw_points WHERE obtained_at >= ? GROUP BY user_id HAVING SUM(points) > 0 ORDER BY SUM(points) DESC, user_id ASC LIMIT ? OFFSET ?",
102102
(rs,row)->this.read(rs),
103103
startDate, size, Math.max(0, (page * size) - size));
104104
}

0 commit comments

Comments
 (0)