# Who messaged the most?

**URL:** https://meta.discourse.org/t/who-messaged-the-most/63963
**Category:** Data & reporting
**Tags:** sql-query
**Created:** [June 5, 2017, 2:37pm UTC](https://meta.discourse.org/t/who-messaged-the-most/63963 "2017-06-05T14:37:58Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![hnaseri](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hnaseri/32/120660_2.png) [@hnaseri](https://meta.discourse.org/u/hnaseri)
#### Post date: [June 5, 2017, 2:37pm UTC](https://meta.discourse.org/t/who-messaged-the-most/63963/1 "2017-06-05T14:37:58Z")

</div>

I am seeing suspicious activity in my user to user private message chart. Its been 20 times more in 3 successive days. now how can I detect who has messaged others the most on those days?

---

<div class="post-metadata">

### Author: ![dax](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dax/32/244677_2.png) [@dax](https://meta.discourse.org/u/dax)
#### Post date: [June 5, 2017, 2:57pm UTC](https://meta.discourse.org/t/who-messaged-the-most/63963/2 "2017-06-05T14:57:07Z")

</div>

If you are an admin you can see the latest PM with a similar link [http://your-site.com/private-posts.rss](http://your-site.com/private-posts.rss) It’s not accurate but you can see if a particular user send more PM in a day.

Or you can run a query to have a list of users and PM in the last X days (you need to install [Data explorer plugin](https://meta.discourse.org/t/data-explorer-plugin/32566)).

Something like this [SQL query to get the queue of all the PMs in the system - #3 by meglio](https://meta.discourse.org/t/sql-query-to-get-the-queue-of-all-the-pms-in-the-system/38089/3) is a good start point to write your own query.

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [June 5, 2017, 2:58pm UTC](https://meta.discourse.org/t/who-messaged-the-most/63963/3 "2017-06-05T14:58:08Z")

</div>

Make sure you have the [Data Explorer](https://meta.discourse.org/t/data-explorer-plugin/32566) plugin installed, navigate to Admin → Plugins → [Data Explorer](https://meta.discourse.org/t/32566?silent=true), create a new query and paste in this SQL code:

```sql
SELECT user_id, count(*) AS message_count
FROM topics
WHERE archetype = 'private_message' AND subtype = 'user_to_user'
AND age(created_at) < interval '7 days'
GROUP BY user_id
ORDER BY message_count DESC

```

This will show you all users that have messaged someone in the last 7 days, including the number of messages they have created. (Only new messages count, replies don’t.)

To see the messages, simply click their username and go to Messages → Sent 🙂

---

<div class="post-metadata">

### Author: ![hnaseri](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hnaseri/32/120660_2.png) [@hnaseri](https://meta.discourse.org/u/hnaseri)
#### Post date: [June 5, 2017, 3:01pm UTC](https://meta.discourse.org/t/who-messaged-the-most/63963/4 "2017-06-05T15:01:40Z")

</div>

I wanted to use that rss link however it only shows me the few recent ones. Is there an option to at least increase the number of message in that rss?

---

<div class="post-metadata">

### Author: ![dax](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dax/32/244677_2.png) [@dax](https://meta.discourse.org/u/dax)
#### Post date: [June 5, 2017, 3:07pm UTC](https://meta.discourse.org/t/who-messaged-the-most/63963/5 "2017-06-05T15:07:17Z")

</div>

> [@hnaseri](#):
>
> Is there an option to at least increase the number of message in that rss?

Sincerly I have no idea if this is possible.

The query that @fefrei share for you is certantly a more accurate method and you can change the interval of days in 2 or 3 instead of 7 if you want

---

<div class="post-metadata">

### Author: ![hnaseri](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hnaseri/32/120660_2.png) [@hnaseri](https://meta.discourse.org/u/hnaseri)
#### Post date: [June 5, 2017, 6:18pm UTC](https://meta.discourse.org/t/who-messaged-the-most/63963/6 "2017-06-05T18:18:24Z")

</div>

It turns out that the culprit is @discobot . I don’t know why its messages are counted as user to user messages. Because to me a bot isn’t a user.

---

<div class="post-metadata">

### Author: ![JagWaugh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jagwaugh/32/69335_2.png) [@JagWaugh](https://meta.discourse.org/u/JagWaugh)
#### Post date: [June 5, 2017, 6:24pm UTC](https://meta.discourse.org/t/who-messaged-the-most/63963/8 "2017-06-05T18:24:34Z")

</div>

Perhaps the user to user stat should ignore user ids less than zero.

(The bot offering to help Hosein just after he wrote that the bot isn’t a user really made me laugh - did it also send you a PM @hnaseri? )

---

<div class="post-metadata">

### Author: ![hnaseri](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hnaseri/32/120660_2.png) [@hnaseri](https://meta.discourse.org/u/hnaseri)
#### Post date: [June 5, 2017, 6:27pm UTC](https://meta.discourse.org/t/who-messaged-the-most/63963/9 "2017-06-05T18:27:00Z")

</div>

😄 Exactly it made me laugh too. No I didn’t get any PM.

> [@JagWaugh](#):
>
> Perhaps the user to user stat should ignore user ids less than zero.

thats a great Idea if possible. Would have saved me couple of hours.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [June 14, 2019, 4:41pm UTC](https://meta.discourse.org/t/who-messaged-the-most/63963/10 "2019-06-14T16:41:09Z")

</div>



---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [November 20, 2022, 5:41pm UTC](https://meta.discourse.org/t/who-messaged-the-most/63963/11 "2022-11-20T17:41:27Z")

</div>



---

<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: [November 20, 2022, 5:46pm UTC](https://meta.discourse.org/t/who-messaged-the-most/63963/12 "2022-11-20T17:46:30Z")

</div>


