FIX: Liked posts based badges were looking at all likes

This commit is contained in:
Robin Ward 2016-04-11 12:36:15 -04:00
parent e4980392da
commit bb25200745
No known key found for this signature in database
GPG Key ID: 0E091E2B4ED1B83D
1 changed files with 4 additions and 1 deletions

View File

@ -240,9 +240,12 @@ SQL
<<-SQL
SELECT us.user_id, current_timestamp AS granted_at
FROM user_stats AS us
WHERE us.likes_received >= #{likes_received}
INNER JOIN posts AS p ON p.user_id = us.user_id
WHERE p.like_count > 0
AND us.likes_given >= #{likes_given}
AND (:backfill OR us.user_id IN (:user_ids))
GROUP BY us.user_id, us.likes_given
HAVING COUNT(*) > #{likes_received}
SQL
end