Skip to content

Instantly share code, notes, and snippets.

@LeoMcA
Last active July 2, 2018 09:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LeoMcA/d881a997fc2e969bd2a894cd884f93e8 to your computer and use it in GitHub Desktop.
Save LeoMcA/d881a997fc2e969bd2a894cd884f93e8 to your computer and use it in GitHub Desktop.
Get notification level statistics for a Discourse category
SELECT replace(replace(replace(replace(replace(cast(notification_level AS varchar), '0', 'muted'), '1', 'regular'), '2', 'tracking'), '3', 'watching'), '4', 'watching first post') AS notification_level, count(*) FROM category_users WHERE category_id=(SELECT id FROM categories WHERE slug='development' AND parent_category_id=(SELECT id FROM categories WHERE slug='add-ons' AND parent_category_id IS NULL)) GROUP BY notification_level;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment