First off, let’s clarify that I’m using myself as an example just to make sure the issue I’m seeing is not a bug somewhere in the badge machinery
The Gives back badge
is granted when you’ve received 100 likes and have given 100 or more likes in return.
Cool! So I gave 464 likes and received 128, I should totally have this badge, but no, I don’t. I see users with similar numbers in likes received/given than me who have it, so what happened? Is a certain ratio needed as with other badges?
Were all of the Likes in Categories that granted badges? i.e. the setting
“Allow badges to be awarded in this category”
* note, messages don’t have a category
If you prefer code the query is
SELECT us.user_id, current_timestamp AS granted_at
FROM user_stats AS us
INNER JOIN posts AS p ON p.user_id = us.user_id
WHERE p.like_count > 0
AND us.likes_given >= 100
AND (:backfill OR us.user_id IN (:user_ids))
GROUP BY us.user_id, us.likes_given
HAVING COUNT(*) > 100
The query is based on the number of posts that have received a like, not the total number of likes received. You’ve only had 57 posts that have received a like.
The short description of “Has 100 liked posts and gave 100 likes” seems more accurate than the long description.