FIX: Fixed getting badges from inviting youself (#19778)

Update invite badge query to exclude self
This commit is contained in:
Ethan 2023-01-26 23:28:47 -05:00 committed by GitHub
parent 48eb8d5f5a
commit da0b401fa5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -160,11 +160,15 @@ module BadgeQueries
FROM invites i
JOIN invited_users iu ON iu.invite_id = i.id
JOIN users u2 ON u2.id = iu.user_id
WHERE i.deleted_at IS NULL AND u2.active AND u2.trust_level >= #{trust_level.to_i} AND u2.silenced_till IS NULL
WHERE i.deleted_at IS NULL
AND i.invited_by_id <> u2.id
AND u2.active
AND u2.trust_level >= #{trust_level.to_i}
AND u2.silenced_till IS NULL
GROUP BY invited_by_id
HAVING COUNT(*) >= #{count.to_i}
) AND u.active AND u.silenced_till IS NULL AND u.id > 0 AND
(:backfill OR u.id IN (:user_ids) )
(:backfill OR u.id IN (:user_ids) )
SQL
end