我正尝试根据帖子的内容授予徽章。
例如,如果我输入“Give Me A Badge”,我就会获得“Demanding”徽章。
我的 SQL 如下:
SELECT p.user_id, p.id post_id, p.updated_at granted_at
FROM badge_posts p
WHERE p.raw LIKE '%Give Me A Badge%'
AND (:backfill OR p.id IN (:post_ids) )
使用“查询目标帖子”和“当用户创建或编辑帖子时”。
然而,它没有被触发。“徽章查询预览”显示了授予的命中次数,但网站似乎没有授予它们。
欢迎提供帮助和建议。
我不幸无法重现
话虽如此,我在 BadgeGranter 中发现了一些可能阻止授予徽章的错误。
main ← fix/badge-granter-resilience
merged 03:31PM - 10 Feb 26 UTC
Two issues were found in BadgeGranter that could prevent badges from being grant… ed.
First, `Array#compact!` returns `nil` when no elements are removed. For PostAction triggers, `[post_id, related_post_id].compact!` returns `nil` when `related_post_id` is present (nothing to compact), causing the post_ids payload to be silently lost. Using `compact` instead always returns the array.
Second, `process_queue!` had no error isolation between badges. A single badge with a broken SQL query would raise an exception and abort processing of all remaining badges in the queue. Since queue items are already popped from Redis at that point, they are lost. Each badge is now rescued individually so one failure doesn't block the rest.
https://meta.discourse.org/t/394444
也许合并后再升级并重试?
有没有可能多提供一点关于你的配置和/或你正在做的事情的信息,这样我才能希望 复现一下?