投稿の内容に応じてバッジを授与しようとしています。
例えば、「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
opened 02:21PM - 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
マージされたら、アップグレードしてもう一度試してみてはいかがでしょうか?