Awarding badges multiple times with custom SQL

I have a badge that’s awarded to people who attend one of our regular events. Because it’s not straightforward to grant badges en masse, I’m using custom SQL to grant the badge. What’s not working, though, is receiving the badge multiple times. I’ve tried to make this work by having one group per event, and including the group’s creation date as the granted_at field:

SELECT
	user_id,
	created_at granted_at,
	NULL post_id
FROM
	group_users
WHERE
	group_id IN (
		SELECT g.id FROM groups g WHERE g.name IN (
			'vit-2016-s2',
			'vit-2017-s1',
			'vit-2017-s2'
		)
	) AND (
		:backfill
		OR user_id IN (:user_ids)
	)

Even though I’m a member of all three of these groups, and in Data Explorer I see three results for my user, there’s still only one instance of the badge that’s granted.

How would I go about changing this so that the badge will automatically be awarded to each user for each group they’re a member of?

Sorry to bump this, but the next round of events is coming up soon and I’d love to have this fixed ahead of time. :wink: Any ideas on how I can grant a badge multiple times without it being linked to a post? (Or should I set the post_id to the announcement post using an ever-growing case statement?)

使用 case 语句并针对帖子进行处理似乎已经解决了这个问题。因此,看起来只有针对帖子的徽章才能多次授予。是否可以在页面上对此进行更清晰的说明?我是否应该重新发布到 Contribute > UXContribute > Feature 来提出这个建议?