Can we delete all 'Automatically Bumped' msgs in one go?

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.

1 Like

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

2 Likes

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.

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

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

4 Likes

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?

The best way would be to do it from the Discourse interface with Data Explorer:

Use the following query:

SELECT * from posts
WHERE action_code = 'autobumped'

3 Likes

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

2 Likes

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


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.

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.

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


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. :+1:

2 Likes

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.

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?

1 Like

Yeah, I checked that before suggesting the data explorer solution.
Adding specific classes to small actions could be a good feature suggestion.

1 Like

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

I haven’t done much with the plugin API, but I did see that there is a method that can add classes to small action posts:

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

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

…and this in the CSS section:

.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.

3 Likes

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

2 Likes

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

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:

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

CSS:

.small-action.bathinda-autobumped {
  display: none;
}
2 Likes

@simonk

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

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

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.

1 Like