FIX: Don't grant sharing badges to users who don't exist (#13851)

In badge queries for 'First Share' and 'Nice/Good/Great Share' badges,
check that the user exists.

For 'Nice+ Share' badges, also grant badges if the number of shares is
equal to the threshhold count to better match the descriptions.
This commit is contained in:
wbhouston
2021-07-27 02:32:59 -04:00
committed by GitHub
parent 1780961e70
commit efe38efb0a
2 changed files with 18 additions and 3 deletions

View File

@ -61,7 +61,7 @@ module BadgeQueries
SELECT i.user_id, MIN(i.id) i_id
FROM incoming_links i
JOIN badge_posts p on p.id = i.post_id
WHERE i.user_id IS NOT NULL
JOIN users u on u.id = i.user_id
GROUP BY i.user_id
) as views
JOIN incoming_links i2 ON i2.id = views.i_id
@ -196,9 +196,9 @@ module BadgeQueries
SELECT i.user_id, MIN(i.id) i_id
FROM incoming_links i
JOIN badge_posts p on p.id = i.post_id
WHERE i.user_id IS NOT NULL
JOIN users u on u.id = i.user_id
GROUP BY i.user_id,i.post_id
HAVING COUNT(*) > #{count}
HAVING COUNT(*) >= #{count}
) as views
JOIN incoming_links i2 ON i2.id = views.i_id
SQL