@Falco Awesome! Quick question .. should this work on previous posts? When I click “Preview granted badges” I get “No badges to be assigned.”
Clicking “Preview with query plan” gives me
GroupAggregate (cost=2021.68..2021.70 rows=1 width=16)
Group Key: p.user_id
-> Sort (cost=2021.68..2021.68 rows=1 width=8)
Sort Key: p.user_id
-> Nested Loop (cost=0.28..2021.67 rows=1 width=8)
Join Filter: (t.category_id = c.id)
-> Nested Loop (cost=0.28..2017.97 rows=1 width=12)
-> Seq Scan on posts p (cost=0.00..2009.66 rows=1 width=12)
Filter: ((deleted_at IS NULL) AND (cooked ~~ '%<span class="math">%'::text) AND (post_type = ANY ('{1,2,3}'::integer[])))
-> Index Scan using topics_pkey on topics t (cost=0.28..8.30 rows=1 width=8)
Index Cond: (id = p.topic_id)
Filter: ((deleted_at IS NULL) AND visible)
-> Seq Scan on categories c (cost=0.00..3.35 rows=28 width=4)
Filter: (allow_badges AND (NOT read_restricted))