# האם ניתן למחוק את כל ההודעות 'נדחפו אוטומטית' בבת אחת?

**URL:** https://meta.discourse.org/t/can-we-delete-all-automatically-bumped-msgs-in-one-go/251038
**Category:** Support
**Created:** [8 בינואר,‏ 2023,‏ 8:59am UTC](https://meta.discourse.org/t/can-we-delete-all-automatically-bumped-msgs-in-one-go/251038 "2023-01-08T08:59:54Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Bathinda](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bathinda/32/135888_2.png) [@Bathinda](https://meta.discourse.org/u/Bathinda)
#### Post date: [8 בינואר,‏ 2023,‏ 8:59am UTC](https://meta.discourse.org/t/can-we-delete-all-automatically-bumped-msgs-in-one-go/251038/1 "2023-01-08T08:59:54Z")

</div>

Searched before posting:  
I like ‘Auto Bumping the topics’ to keep topics getting renewed. But I wished that when visitor visited topics, they weren’t shown tens of ‘Automatically Bumped’ msgs.

Is there a way to delete them occasionally, manually or automatically (or both)?

I’m asking this because I’ve found that at my level, whatever my wish happens to be, the same is mostly already been taken care of.

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [8 בינואר,‏ 2023,‏ 3:04pm UTC](https://meta.discourse.org/t/can-we-delete-all-automatically-bumped-msgs-in-one-go/251038/2 "2023-01-08T15:04:33Z")

</div>

Hi @Bathinda!  
You can manually click on the delete icon, like any other post:

---

<div class="post-metadata">

### Author: ![Bathinda](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bathinda/32/135888_2.png) [@Bathinda](https://meta.discourse.org/u/Bathinda)
#### Post date: [9 בינואר,‏ 2023,‏ 4:32am UTC](https://meta.discourse.org/t/can-we-delete-all-automatically-bumped-msgs-in-one-go/251038/3 "2023-01-09T04:32:21Z")

</div>

> [@Canapin](#):
>
> nually click on the delete icon, like any other

Thanks, but that’s not practical way of deleting hundreds of bumping msgs on different topics.

I even couldn’t select all ‘bump’ msgs on even one single topic.

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [9 בינואר,‏ 2023,‏ 9:23am UTC](https://meta.discourse.org/t/can-we-delete-all-automatically-bumped-msgs-in-one-go/251038/4 "2023-01-09T09:23:17Z")

</div>

There is no built-in feature for such a bulk action.

You could use a rails script to delete existing auto bump messages, something like:

1. SSH in your server

2. `cd /var/discourse`

3. `./launcher enter app`

4. `rails c`

5. `Post.where("action_code = 'autobumped'").destroy_all`

⚠ Always do a backup first of course, just in case.

---

<div class="post-metadata">

### Author: ![Bathinda](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bathinda/32/135888_2.png) [@Bathinda](https://meta.discourse.org/u/Bathinda)
#### Post date: [9 בינואר,‏ 2023,‏ 10:54am UTC](https://meta.discourse.org/t/can-we-delete-all-automatically-bumped-msgs-in-one-go/251038/5 "2023-01-09T10:54:32Z")

</div>

That’s good enough.  
Thank you.

Is there some command with which we could first list/see all those msgs before giving the ‘destroy (delete)’ command?

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [9 בינואר,‏ 2023,‏ 11:36am UTC](https://meta.discourse.org/t/can-we-delete-all-automatically-bumped-msgs-in-one-go/251038/6 "2023-01-09T11:36:52Z")

</div>

The best way would be to do it from the Discourse interface with [Data Explorer](https://meta.discourse.org/t/32566?silent=true):

> [@Discourse Data Explorer](https://meta.discourse.org/t/discourse-data-explorer/32566):
>
> discourse2Summary Discourse [Data Explorer](https://meta.discourse.org/t/32566?silent=true) allows you to make SQL queries against your live database, allowing for up-to-the-minute stats reporting.open_bookInstall Guide This plugin is bundled with Discourse core. There is no need to install the plugin separately.information_source If you’re looking for examples or support for any custom queries, you can find lots of topics in our #Data & reporting category under the #sql-query tag. If there’s not one to suit your pa…

Use the following query:

```sql
SELECT * from posts
WHERE action_code = 'autobumped'

```

 ![auto bump data explorer query result](https://global.discourse-cdn.com/meta/original/4X/8/3/1/831d3acb272224c6f07a346f2e2bc9a867bb4f83.png)

---

<div class="post-metadata">

### Author: ![Bathinda](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bathinda/32/135888_2.png) [@Bathinda](https://meta.discourse.org/u/Bathinda)
#### Post date: [9 בינואר,‏ 2023,‏ 12:13pm UTC](https://meta.discourse.org/t/can-we-delete-all-automatically-bumped-msgs-in-one-go/251038/7 "2023-01-09T12:13:27Z")

</div>

Ah!! That’s the query, which would make me happy. Thanks again.

---

<div class="post-metadata">

### Author: ![Bathinda](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bathinda/32/135888_2.png) [@Bathinda](https://meta.discourse.org/u/Bathinda)
#### Post date: [13 בינואר,‏ 2023,‏ 7:20am UTC](https://meta.discourse.org/t/can-we-delete-all-automatically-bumped-msgs-in-one-go/251038/8 "2023-01-13T07:20:28Z")

</div>

Though the query suggested does show the topics that contain ‘auto-bumped’ msgs in all topics. But it proved of not much help.

 ![image](https://global.discourse-cdn.com/meta/original/4X/d/f/e/dfe3308d356e42212fad742a4ad53c6721342886.png)  
It just returns hundreds of topics which contain thousands of ‘Auto-Bumped’ msgs, but doesn’t tell how many such msgs exist in how many topics.

So, I think, ultimately I’ll have to wield the axe in the ‘dark rooms’ of rails console only (which is a bit intimidating).

I’m a bit worrisome because it’ll affect thousands of topics/posts in one go. If only there were some `select all` button inside topics which would select all the bumping msgs together and we could delete those msgs with one click inside any topic. And if anyone wanted to delete **all such msgs** in _ **All Topics** _ with just **one command** only then he’d have to enter ‘rails’.

I’m not complaining. I’m just expressing myself.

---

<div class="post-metadata">

### Author: ![Bathinda](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bathinda/32/135888_2.png) [@Bathinda](https://meta.discourse.org/u/Bathinda)
#### Post date: [13 בינואר,‏ 2023,‏ 7:57am UTC](https://meta.discourse.org/t/can-we-delete-all-automatically-bumped-msgs-in-one-go/251038/9 "2023-01-13T07:57:36Z")

</div>

> [@Canapin](#):
>
> 1. Post.where(“action\_code = ‘autobumped’”).destroy\_all

Would the 5th line of the rails command told by you would ask or prompt anything before deleting all those posts? Or would it just do what it has been told to do, without any warning etc, or chance of retrieval?

If possible, can we delete ‘bumping msgs’ from anyone topic first, instead of deleting from whole website?

Also, can you pls suggest/tell any rails command to view some samples of the posts which we’re going to delete?

Thanks.

---

<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: [13 בינואר,‏ 2023,‏ 9:51am UTC](https://meta.discourse.org/t/can-we-delete-all-automatically-bumped-msgs-in-one-go/251038/10 "2023-01-13T09:51:00Z")

</div>

Something like this in the data-explorer may help give an overview:

```sql

SELECT p.topic_id,
       COUNT(p.id) AS count
FROM posts p
WHERE action_code = 'autobumped'
GROUP BY p.topic_id
ORDER BY count DESC

```

However, I’ll chuck in a word of warning about using the rails console to make changes like these on a live site if you’re inexperienced with it. You may want to spin up a test site and have a practice before diving in. 👍

---

<div class="post-metadata">

### Author: ![Bathinda](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bathinda/32/135888_2.png) [@Bathinda](https://meta.discourse.org/u/Bathinda)
#### Post date: [13 בינואר,‏ 2023,‏ 10:50am UTC](https://meta.discourse.org/t/can-we-delete-all-automatically-bumped-msgs-in-one-go/251038/11 "2023-01-13T10:50:36Z")

</div>

Yeah it did solve problem as much as offered by the designers/developers.

But I still would like to say that there should be some ‘Admin’ commandj, in the admin settings or in the topic being viewed, to select all '_**duplicate (Auto-Bumped) msgs’**_ in any one topic or all topics and then remove them, whenever admin wished.

---

<div class="post-metadata">

### Author: ![simonk](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simonk/32/247950_2.png) [@simonk](https://meta.discourse.org/u/simonk)
#### Post date: [13 בינואר,‏ 2023,‏ 11:07am UTC](https://meta.discourse.org/t/can-we-delete-all-automatically-bumped-msgs-in-one-go/251038/12 "2023-01-13T11:07:11Z")

</div>

Perhaps you could hide those messages with CSS instead? Unfortunately, I don’t think the `post-small-action` widget currently includes the action type as a CSS class, so you can’t target bump messages specifically. Maybe a theme component could help?

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [13 בינואר,‏ 2023,‏ 11:09am UTC](https://meta.discourse.org/t/can-we-delete-all-automatically-bumped-msgs-in-one-go/251038/13 "2023-01-13T11:09:59Z")

</div>

> [@simonk](#):
>
> Unfortunately, I don’t think the `post-small-action` widget currently includes the action type as a CSS class

Yeah, I checked that before suggesting the [data explorer](https://meta.discourse.org/t/32566?silent=true) solution.  
Adding specific classes to small actions could be a good #Contribute > Feature suggestion.

---

<div class="post-metadata">

### Author: ![Bathinda](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bathinda/32/135888_2.png) [@Bathinda](https://meta.discourse.org/u/Bathinda)
#### Post date: [13 בינואר,‏ 2023,‏ 11:21am UTC](https://meta.discourse.org/t/can-we-delete-all-automatically-bumped-msgs-in-one-go/251038/14 "2023-01-13T11:21:05Z")

</div>

Can you suggest some thing pls.  
I can just copy paste the same into a component. Don’t know the coding.

---

<div class="post-metadata">

### Author: ![simonk](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simonk/32/247950_2.png) [@simonk](https://meta.discourse.org/u/simonk)
#### Post date: [13 בינואר,‏ 2023,‏ 12:04pm UTC](https://meta.discourse.org/t/can-we-delete-all-automatically-bumped-msgs-in-one-go/251038/15 "2023-01-13T12:04:43Z")

</div>

I haven’t done much with [the plugin API](https://meta.discourse.org/t/beginners-guide-to-developing-discourse-themes/93648#the-pluginapi-25), but I did see that there is a method that can add classes to small action posts:

> <https://github.com/discourse/discourse/blob/ce6335693a4a110848a1bde87f245549d6f626ad/app/assets/javascripts/discourse/app/lib/plugin-api.js#L938>

So I made a theme component that included this in the **Head** section:

```js
<script type="text/discourse-plugin" version="1.6.0">
  api.addPostSmallActionClassesCallback(post => {
    return ["small-action-" + post.actionCode]
  });
</script>

```

…and this in the **CSS** section:

```css
.small-action.small-action-autobumped {
  display: none;
}

```

…and the autobumped message disappeared!

I haven’t done any other testing, so I don’t know if there would be any other side effects. It’s possible that `small-action-[...]` classes might clash somewhere else in the application, in which case you should choose a prefix that is guaranteed to be unique.

---

<div class="post-metadata">

### Author: ![simonk](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simonk/32/247950_2.png) [@simonk](https://meta.discourse.org/u/simonk)
#### Post date: [13 בינואר,‏ 2023,‏ 12:11pm UTC](https://meta.discourse.org/t/can-we-delete-all-automatically-bumped-msgs-in-one-go/251038/16 "2023-01-13T12:11:57Z")

</div>

Note that the `addPostSmallActionClassesCallback` method was only added last month, so you need to be on a fairly recent version of Discourse:

[https://github.com/discourse/discourse/pull/19453](https://github.com/discourse/discourse/pull/19453)

---

<div class="post-metadata">

### Author: ![Bathinda](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bathinda/32/135888_2.png) [@Bathinda](https://meta.discourse.org/u/Bathinda)
#### Post date: [13 בינואר,‏ 2023,‏ 12:35pm UTC](https://meta.discourse.org/t/can-we-delete-all-automatically-bumped-msgs-in-one-go/251038/18 "2023-01-13T12:35:19Z")

</div>

Thanks.  
Pls elaborate this last `in which case you should choose a prefix that is guaranteed to be unique.`

---

<div class="post-metadata">

### Author: ![simonk](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simonk/32/247950_2.png) [@simonk](https://meta.discourse.org/u/simonk)
#### Post date: [13 בינואר,‏ 2023,‏ 12:39pm UTC](https://meta.discourse.org/t/can-we-delete-all-automatically-bumped-msgs-in-one-go/251038/19 "2023-01-13T12:39:04Z")

</div>

For example, you could use the prefix `bathinda-`, which would be guaranteed not to clash with anything in Discourse either now or in the future. It would look something like this:

**Head** :

```js
<script type="text/discourse-plugin" version="1.6.0">
  api.addPostSmallActionClassesCallback(post => {
    return ["bathinda-" + post.actionCode]
  });
</script>

```

**CSS** :

```css
.small-action.bathinda-autobumped {
  display: none;
}

```

---

<div class="post-metadata">

### Author: ![Bathinda](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bathinda/32/135888_2.png) [@Bathinda](https://meta.discourse.org/u/Bathinda)
#### Post date: [15 בינואר,‏ 2023,‏ 11:25am UTC](https://meta.discourse.org/t/can-we-delete-all-automatically-bumped-msgs-in-one-go/251038/20 "2023-01-15T11:25:17Z")

</div>

@simonk

Thanks again. Created and used/activated the component successfully.  
Though after hiding ‘Automatically Bumped’ msgs, it looks like this.

 ![image](https://global.discourse-cdn.com/meta/original/4X/d/1/6/d1617cb45f62fd18cd1e0ed6f13c0adff699cb6b.png)

Bit ‘unlikable’, better than none/other solutions.

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [15 בינואר,‏ 2023,‏ 12:36pm UTC](https://meta.discourse.org/t/can-we-delete-all-automatically-bumped-msgs-in-one-go/251038/21 "2023-01-15T12:36:15Z")

</div>

Ah I see, it’s because of the time-gap messages that aren’t hidden. This is tricky because you can’t target a **previous** element with CSS.

[Next page](https://meta.discourse.org/t/can-we-delete-all-automatically-bumped-msgs-in-one-go/251038.md?page=2)
