Category lurkers

Category lurkers:

See for a category (or all categories by default) the users’ notification level.
rationale: we use categories for “working groups” that everyone can “join” (track or watch). Therefore, a working group member is someone that has a notification level set for this category, and this query lists the members

-- [params]
-- null int :category 

select category_id, cu.user_id,
CASE notification_level 
  WHEN 1 THEN 'regular'
  WHEN 2 THEN 'tracking'
  WHEN 3 THEN 'watching'
  WHEN 4 THEN 'watching_first_post'
END as level

from category_users cu
join categories on category_id=categories.id
where (:category is null OR category_id= :category)
order by category_id, notification_level desc
5 Likes