Skip to content

Commit

Permalink
move QOTW points check after summation
Browse files Browse the repository at this point in the history
  • Loading branch information
danthe1st committed Dec 29, 2024
1 parent ae8208f commit aebc8ad
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public List<QOTWAccount> sortByPoints(LocalDate startDate) throws DataAccessExce
* @throws DataAccessException If an error occurs.
*/
public List<QOTWAccount> getTopAccounts(LocalDate startDate, int page, int size) throws DataAccessException {
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 ?",
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 ?",
(rs,row)->this.read(rs),
startDate, size, Math.max(0, (page * size) - size));
}
Expand Down

0 comments on commit aebc8ad

Please sign in to comment.