# Viewing a list of users who are watching a category

**URL:** https://meta.discourse.org/t/viewing-a-list-of-users-who-are-watching-a-category/15225
**Category:** Feature
**Created:** [1 Maio , 2014 18:01 UTC](https://meta.discourse.org/t/viewing-a-list-of-users-who-are-watching-a-category/15225 "2014-05-01T18:01:43Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![wesochuck](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wesochuck/32/108706_2.png) [@wesochuck](https://meta.discourse.org/u/wesochuck)
#### Post date: [1 Maio , 2014 18:01 UTC](https://meta.discourse.org/t/viewing-a-list-of-users-who-are-watching-a-category/15225/1 "2014-05-01T18:01:43Z")

</div>

We’d like a way to see which users have added a category to their watch list. Ideally this information would be able to be exposed to mods as well, or handled as a new security “type” for the category security settings.

Our use case is that we have mods that we assign to “check-in” with users to make sure that they are subscribing to a particular category and getting updates. Right now there is no real way that we can see to expose that information without going into each user account in admin and checking their preferences.

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [1 Maio , 2014 19:02 UTC](https://meta.discourse.org/t/viewing-a-list-of-users-who-are-watching-a-category/15225/2 "2014-05-01T19:02:50Z")

</div>

I like statistics and I’m always open to learning different approaches at moderating.

I can see how this feature would be an interesting type of “success metric”, but I can’t envision how this could be applied to moderation tasks.

Please explain further. Thanks.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [1 Maio , 2014 19:33 UTC](https://meta.discourse.org/t/viewing-a-list-of-users-who-are-watching-a-category/15225/3 "2014-05-01T19:33:13Z")

</div>

Probably you could

- write a plugin that does this
- export the DB and query it
- write a script that runs on the Discourse server and queries the live DB

---

<div class="post-metadata">

### Author: ![wesochuck](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wesochuck/32/108706_2.png) [@wesochuck](https://meta.discourse.org/u/wesochuck)
#### Post date: [2 Maio , 2014 01:12 UTC](https://meta.discourse.org/t/viewing-a-list-of-users-who-are-watching-a-category/15225/4 "2014-05-02T01:12:02Z")

</div>

> [@Mittineague](#):
>
> I can’t envision how this could be applied to moderation tasks.

One of our moderators’ tasks is to ensure signup of members. We’re talking about a few dozen folks here, not hundreds. But it is the moderator’s job to make sure that everyone is participating in the community. So if they could see who was **not** signed up, they would followup with that user at one of the quarterly in-person meetings we have with our community members.

We have a developer, but he has no experience with the _stack_ that Discourse is built on. Maybe we’ll consider offering a bounty to someone out there if this becomes a major issue in the future.

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [2 Maio , 2014 02:59 UTC](https://meta.discourse.org/t/viewing-a-list-of-users-who-are-watching-a-category/15225/5 "2014-05-02T02:59:15Z")

</div>

Thanks for getting back. Now I understand. I can’t see it being useful for our forum at the moment but if it ever does I’ll now have an idea on how to go about it.

---

<div class="post-metadata">

### Author: ![nukeador](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nukeador/32/107477_2.png) [@nukeador](https://meta.discourse.org/u/nukeador)
#### Post date: [22 Outubro , 2015 19:30 UTC](https://meta.discourse.org/t/viewing-a-list-of-users-who-are-watching-a-category/15225/6 "2015-10-22T19:30:54Z")

</div>

@wesochuck did you manage to solve this?

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [22 Outubro , 2015 20:11 UTC](https://meta.discourse.org/t/viewing-a-list-of-users-who-are-watching-a-category/15225/7 "2015-10-22T20:11:25Z")

</div>

You should be able to use the [Data Explorer](https://meta.discourse.org/t/32566?silent=true) Plugin to do this.

---

<div class="post-metadata">

### Author: ![nukeador](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nukeador/32/107477_2.png) [@nukeador](https://meta.discourse.org/u/nukeador)
#### Post date: [22 Outubro , 2015 21:00 UTC](https://meta.discourse.org/t/viewing-a-list-of-users-who-are-watching-a-category/15225/8 "2015-10-22T21:00:57Z")

</div>

> [@cpradio](#):
>
> You should be able to use the [Data Explorer](https://meta.discourse.org/t/32566?silent=true) Plugin to do this.

Sure, but that’s like basically run a query to the DB, right? I would be cool to have to info somehow on the admin stats.

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [22 Outubro , 2015 21:04 UTC](https://meta.discourse.org/t/viewing-a-list-of-users-who-are-watching-a-category/15225/9 "2015-10-22T21:04:40Z")

</div>

You run the query in the admin UI under the Plugins area.

---

<div class="post-metadata">

### Author: ![wesochuck](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wesochuck/32/108706_2.png) [@wesochuck](https://meta.discourse.org/u/wesochuck)
#### Post date: [23 Outubro , 2015 14:51 UTC](https://meta.discourse.org/t/viewing-a-list-of-users-who-are-watching-a-category/15225/10 "2015-10-23T14:51:48Z")

</div>

Since our major goal was to provide this information to moderators, we used the badge system to accomplish this for our purposes.

Here is what we did:

1. Created a badge that mirrored the category name
2. Set the badge trigger to run daily
3. Used this SQL for the badge query

````plaintext
    select user_id, current_timestamp granted_at from category_users
    where notification_level = 3
    and category_id = 15
    union all
    select id, current_timestamp granted_at from users where mailing_list_mode = 't'```
 1. notification_level = 3 ~~ means they are tracking the category
 1. category_id = 15 ~~ is the category number that we're using the badge to represent
 1. mailing_list_mode = 't' ~~ says if they are in mailing list mode (getting notified for ALL messages into the system) then we will also count them as a subscriber for the category too.

Now a moderator can look at ```/badges``` and determine who is Watching their category.

There are a few tweaks that we should do to improve the badge on the SQL, those include:

1. Someone could be in mailing_list_mode, but they might have MUTED a category, we should take that into consideration
1. notification_level could possibly be switched to >= 2 so it would also capture if they were TRACKING or WATCHING a category.

The release of the data explorer could also be a big help, we just haven't had a chance to play with that much yet.
````

---

<div class="post-metadata">

### Author: ![nukeador](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nukeador/32/107477_2.png) [@nukeador](https://meta.discourse.org/u/nukeador)
#### Post date: [24 Outubro , 2015 19:47 UTC](https://meta.discourse.org/t/viewing-a-list-of-users-who-are-watching-a-category/15225/11 "2015-10-24T19:47:43Z")

</div>

> [@wesochuck](#):
>
> select user\_id, current\_timestamp granted\_at from category\_userswhere notification\_level = 3and category\_id = 15union allselect id, current\_timestamp granted\_at from users where mailing\_list\_mode = ‘t’

I’m getting this error:

```
Contract violation:
Query triggers on users, but does not reference the ':user_ids' array

```

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [24 Outubro , 2015 20:42 UTC](https://meta.discourse.org/t/viewing-a-list-of-users-who-are-watching-a-category/15225/12 "2015-10-24T20:42:39Z")

</div>

OK, if you want it to trigger, then do this:

```plaintext
select user_id, current_timestamp granted_at from category_users
where notification_level = 3
and category_id = 15
and (:backfill OR (user_id IN (:user_ids)))
union all
select id, current_timestamp granted_at from users where mailing_list_mode = 't'
and (:backfill OR (id IN (:user_ids)))

```

---

<div class="post-metadata">

### Author: ![nukeador](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nukeador/32/107477_2.png) [@nukeador](https://meta.discourse.org/u/nukeador)
#### Post date: [1 Julho , 2016 21:15 UTC](https://meta.discourse.org/t/viewing-a-list-of-users-who-are-watching-a-category/15225/13 "2016-07-01T21:15:11Z")

</div>

I guess fields have changed because now I get:

```plaintext
ERROR: column "mailing_list_mode" does not exist
LINE 6: ...id, current_timestamp granted_at from users where mailing_li...

```

---

<div class="post-metadata">

### Author: ![wesochuck](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wesochuck/32/108706_2.png) [@wesochuck](https://meta.discourse.org/u/wesochuck)
#### Post date: [2 Julho , 2016 03:58 UTC](https://meta.discourse.org/t/viewing-a-list-of-users-who-are-watching-a-category/15225/14 "2016-07-02T03:58:51Z")

</div>

The table is now: user\_options and the column name is mailing\_list\_mode (which is a boolean field true / false).

---

<div class="post-metadata">

### Author: ![nukeador](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nukeador/32/107477_2.png) [@nukeador](https://meta.discourse.org/u/nukeador)
#### Post date: [2 Julho , 2016 12:49 UTC](https://meta.discourse.org/t/viewing-a-list-of-users-who-are-watching-a-category/15225/15 "2016-07-02T12:49:43Z")

</div>

The updated query working today is:

```plaintext
select user_id, current_timestamp granted_at from category_users
where notification_level = 3
and category_id = 15
and (:backfill OR (user_id IN (:user_ids)))
union all
select user_id, current_timestamp granted_at from user_options where mailing_list_mode = True
and (:backfill OR (user_id IN (:user_ids)))

```

---

<div class="post-metadata">

### Author: ![chapoi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chapoi/32/537252_2.png) [@chapoi](https://meta.discourse.org/u/chapoi)
#### Post date: [4 Dezembro , 2025 11:14 UTC](https://meta.discourse.org/t/viewing-a-list-of-users-who-are-watching-a-category/15225/16 "2025-12-04T11:14:22Z")

</div>


