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)

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)

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

إعجاب واحد (1)

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

Is this a development server, or production?

إعجاب واحد (1)

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)

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)

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)

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)

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)

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)

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 إعجابات

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)

Ah good - that makes this much simpler to solve!

Yes, the trigger button is safe :slight_smile:

إعجابَين (2)

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)

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 إعجابات

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)