How to force grant all badges from command line?

Badges are granted once per day.
Is there a way to schedule / force the granting process “right now” from command line?

1 Like

Easiest way is to visit /sidekiq/scheduler and look for any jobs with the word “grant” in the name. You probably want Jobs::BadgeGrant, but some badges have their own tasks.

2 Likes

I went through all scheduled tasks in sidekiq up to 24 hours from now, and none have grant token in them.

1 Like

Oh… weird. So you don’t see a line like this?

Is this a development server, or production?

1 Like

It’s in production forum.kozovod.com.
Correct, no entries like on your screenshot.

I just noticed I had no badges granted for a long time. Rebuilding the container now and will check if the task will be scheduled after restart.

Also, I noticed that one of my custom-sql badges had an error - could it stop all other badges from working?

2 Likes

In theory, no.

I think the most likely thing is a docker-manager update gone wrong, and so some sidekiq jobs had failed to load. Hopefully once you rebuild it will work.

1 Like

Okay, rebuild went well.

However, in a few minutes after it is complete, I still can’t find any grant token in all 125+ scheduled tasks. Does it mean something is failing with my setup?

1 Like

Yes, probably. Do you have any errors in /logs? Any unusual plugins?

Hm nothing critical in the latest ~20 minutes:

Can you see anything suspicious that can break the badges execution / scheduling?

1 Like

Can’t see anything obvious. If you go into a console and type Jobs::BadgeGrant, what happens? Should look like this:

[1] pry(main)> Jobs::BadgeGrant
=> Jobs::BadgeGrant
1 Like

Okay here it is:

image

After that, no new errors in /logs.

Nor are there new entries with the grant token in /sidekiq/scheduled

1 Like

Do you have any plugins which could be interfering?

here are enabled ones - I try to use popular and supported ones only:

          - git clone https://github.com/discourse/docker_manager.git
          - git clone https://github.com/discourse/discourse-data-explorer.git
          - git clone https://github.com/discourse/discourse-staff-notes.git
          - git clone https://github.com/joebuhlig/discourse-feature-voting.git
          - git clone https://github.com/discourse/discourse-checklist.git
          - git clone https://github.com/discourse/discourse-cakeday.git
          - git clone https://github.com/discourse/discourse-saved-searches.git
          - git clone https://github.com/discourse/discourse-canned-replies.git
          - git clone https://github.com/discourse/discourse-assign.git
          - git clone https://github.com/discourse/discourse-bbcode.git
          - git clone https://github.com/angusmcleod/discourse-locations.git
          - git clone https://github.com/discourse/discourse-adplugin.git
          - git clone https://github.com/angusmcleod/discourse-custom-wizard.git

Just checking - are you looking in “Scheduled” or “Scheduler”? The badge jobs should be under Scheduler.

(Aside: wow that’s confusing naming!)

5 Likes

Thanks.
Under Scheduler, I can now see the following ones:

  • Jobs::GrantNewUserOfTheMonthBadges
  • Jobs::GrantAnniversaryBadges
  • Jobs::BadgeGrant

All Scheduler jobs apper under the " Recurring Jobs" section.

Now, is it safe for me to click on the “Trigger” button and see what happens?

1 Like

Ah good - that makes this much simpler to solve!

Yes, the trigger button is safe :slight_smile:

2 Likes

Thanks, running now.

Last time it took 10k seconds, so will check back tomorrow morning.

Is there any way to process one particular badge? Maybe from command line?

1 Like

10k seconds is a lot! On meta, it takes 500 seconds. Maybe one of your custom badge queries is not very efficient? (that’s why we disable the custom SQL feature by default)

3 Likes

Thanks, I reviewed queries quickly and fixed one a bit and it only took ~1k seconds now. I also cross-posted my SQL-optimization question in a separate topic.

Back to the badges - it now worked and all badges are granted. Thank you for your assistance and prompt replies.

2 Likes