# \[Paid\] Prune Spam users

**URL:** <https://meta.discourse.org/t/paid-prune-spam-users/63132>\
**Category:** Marketplace\
**Created:** [May 22, 2017, 10:28am UTC](https://meta.discourse.org/t/paid-prune-spam-users/63132 "2017-05-22T10:28:42Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![MakaryGo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/makarygo/32/187426_2.png) [@MakaryGo](https://meta.discourse.org/u/MakaryGo)\
**Post date:** [May 22, 2017, 11:09am UTC](https://meta.discourse.org/t/paid-prune-spam-users/63132/3 "2017-05-22T11:09:46Z")

</div>

`User.joins(:user_stat).where("user_stats.post_count = 0 AND previous_visit_at <= '2016-05-22'::timestamp").destroy_all`  
Should do the trick 🙂 Of course make sure to make a backup first 🙂  
Edit:  
Sorry, forgot usage tips 🙂 Of course you have to log into your server, go into the discourse directory [probably /var/discourse], enter your Docker container [probably `./launcher enter app`] and then enter rails console by typing `rails c` . These are defaults on docker based installations 🙂  
@treb0r

---

_[View the full topic](https://meta.discourse.org/t/paid-prune-spam-users/63132)._
