Description: A user requested I revoke their First Like badge after they, themselves, un-liked a post, but the badge kept getting re-granted. Context can be found at my previous post in the support category.
Reproducible steps:
- Create a new user
- Like a post
- Receive the First Like badge
- Un-like the post
- Switch to an admin user
- Go to the admin panel for the user who liked the post
- Visit the Edit Badges option
- Click “Revoke” on the First Like badge
- Wait a bit (I’m not sure when does the backfill job run for this particular badge, but a day will surely do. Maybe try triggering all the badge-related jobs in Sidekiq to speed it up?)
- The badge is granted back to the user automatically, for the same post that was disliked and at the same date that the like was made
I have narrowed down the issue to this line of the SQL query for granting the badge, because, while the row in post_actions
for the like action still exists after un-liking, it has its deleted_at
column set to a date value, which the query does not take into account. I believe the fix for this would change the WHERE clause of the subquery to:
WHERE post_action_type_id = 2 AND
pa.deleted_at IS NULL AND
(:backfill OR pa.post_id IN (:post_ids) )
but I don’t have a development environment set up or a lot of time to test out this fix myself.
Priority/Severity: I have solved this issue for myself by deleting the relevant post_actions
rows already, and I’ve never received such a request before. I guess that doesn’t make it very high priority?