Awarding badges multiple times with custom SQL

AI 生成的摘要

barryvan is using custom SQL to award a badge to users who attend regular events, but the badge is only granted once per user despite membership in multiple event groups. Even though the SQL query returns multiple results per user (one per group), the system only awards the badge once. barryvan follows up, seeking a solution to grant the badge multiple times without linking it to posts. In post 3, barryvan reports success by using a CASE statement to assign the badge to specific announcement posts, suggesting that non-manually awarded badges can only be granted multiple times if tied to posts. They ask whether this limitation should be documented more clearly or suggested as a feature/UX improvement on ux or #feature.

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 > UX 或 Contribute > Feature 来提出这个建议?