# 员工回复的查询包括开启和关闭主题等操作

**URL:** https://meta.discourse.org/t/query-of-replies-made-by-staff-includes-actions-like-opening-and-closing-threads/82535
**Category:** Support
**Created:** [2018年三月8日 18:00 UTC](https://meta.discourse.org/t/query-of-replies-made-by-staff-includes-actions-like-opening-and-closing-threads/82535 "2018-03-08T18:00:47Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![jerdog](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jerdog/32/122843_2.png) [@jerdog](https://meta.discourse.org/u/jerdog)
#### Post date: [2018年三月8日 18:00 UTC](https://meta.discourse.org/t/query-of-replies-made-by-staff-includes-actions-like-opening-and-closing-threads/82535/1 "2018-03-08T18:00:47Z")

</div>

I am building queries for my community to be able to fulfill some metrics, and what I am seeing is something I can’t seem to get around. The following query essentially just pulls back all posts made by staff members during a time period, but also includes activities like opening/closing a topic, etc.

```
-- [params]
-- string :start = 2018-03-04 00:00:00
-- string :end = 2018-03-10 23:59:59.999999

SELECT p.user_id, count(p.id) as Replies
    FROM posts p
    WHERE p.created_at between :start and :end AND
        p.user_id IN 
        (select u.id 
            from users u
            where u.primary_group_id = 41) AND
        p.user_id not in ('-1', '-2') AND
        p.topic_id not in ('4','24','26','32','33','34','35','36','37','38','39','40')
GROUP BY p.user_id
ORDER BY Replies DESC

```

I see a `post_action_types` table but it has things like Likes, Bookmarks, etc.. I am trying to get to where I am displaying actual replies by my staff and not just things like “likes” and such

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [2018年三月8日 18:10 UTC](https://meta.discourse.org/t/query-of-replies-made-by-staff-includes-actions-like-opening-and-closing-threads/82535/2 "2018-03-08T18:10:03Z")

</div>

You should filter only regular posts by `WHERE p.post_type = 1`.

Available post types are `regular: 1, moderator_action: 2, small_action: 3, whisper: 4`.

---

<div class="post-metadata">

### Author: ![jerdog](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jerdog/32/122843_2.png) [@jerdog](https://meta.discourse.org/u/jerdog)
#### Post date: [2018年三月8日 18:21 UTC](https://meta.discourse.org/t/query-of-replies-made-by-staff-includes-actions-like-opening-and-closing-threads/82535/3 "2018-03-08T18:21:07Z")

</div>

> [@vinothkannans](#):
>
> p.post\_type = 1

Brilliant. Thanks mate.

---

<div class="post-metadata">

### Author: ![jerdog](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jerdog/32/122843_2.png) [@jerdog](https://meta.discourse.org/u/jerdog)
#### Post date: [2018年三月26日 14:10 UTC](https://meta.discourse.org/t/query-of-replies-made-by-staff-includes-actions-like-opening-and-closing-threads/82535/4 "2018-03-26T14:10:10Z")

</div>

> [@vinothkannans](#):
>
> Available post types are `regular: 1, moderator_action: 2, small_action: 3, whisper: 4`.

What would classify as a “small\_action”?

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [2018年三月26日 14:13 UTC](https://meta.discourse.org/t/query-of-replies-made-by-staff-includes-actions-like-opening-and-closing-threads/82535/5 "2018-03-26T14:13:05Z")

</div>

Stuff like this:

 ![image](https://global.discourse-cdn.com/meta/original/3X/4/f/4ff914e8d1dcc56b39514c2d9eb7d05df982f57d.png)

---

<div class="post-metadata">

### Author: ![jerdog](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jerdog/32/122843_2.png) [@jerdog](https://meta.discourse.org/u/jerdog)
#### Post date: [2018年三月26日 14:38 UTC](https://meta.discourse.org/t/query-of-replies-made-by-staff-includes-actions-like-opening-and-closing-threads/82535/6 "2018-03-26T14:38:55Z")

</div>

Perfect -thanks for the clarification

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [2024年六月8日 12:37 UTC](https://meta.discourse.org/t/query-of-replies-made-by-staff-includes-actions-like-opening-and-closing-threads/82535/7 "2024-06-08T12:37:40Z")

</div>

此主题已在 2283 天后自动关闭。不再允许回复。
