Badge SQL can no longer be edited by default

Yes, send an email to team@discourse.org with the request, they’ll take care of you.

7 Likes

is this an old guide?

It’s SiteSetting and not SiteSettings.

9 Likes

I executed ./launcher enter app and then rails c, but it doesn’t seem to start right.

After starting, it doesn’t print out anything and it doesn’t react either. Any idea?

root@scw-1a7c81-app:/var/www/discourse# rails c
^Cbundler: failed to load command: pry (/var/www/discourse/vendor/bundle/ruby/2.4.0/bin/pry)
Interrupt: 
  /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.8/lib/active_support/core_ext/class/subclasses.rb:8:in `<class:Class>'
  /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.8/lib/active_support/core_ext/class/subclasses.rb:4:in `<top (required)>'
  /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.8/lib/active_support/core_ext/class.rb:3:in `require'
  /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.8/lib/active_support/core_ext/class.rb:3:in `<top (required)>'
  /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionmailer-4.2.8/lib/action_mailer.rb:29:in `require'
  /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionmailer-4.2.8/lib/action_mailer.rb:29:in `<top (required)>'
  /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionmailer-4.2.8/lib/action_mailer/railtie.rb:2:in `require'
  /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionmailer-4.2.8/lib/action_mailer/railtie.rb:2:in `<top (required)>'
  /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/railties-4.2.8/lib/rails/all.rb:13:in `require'
  /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/railties-4.2.8/lib/rails/all.rb:13:in `block in <top (required)>'
  /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/railties-4.2.8/lib/rails/all.rb:11:in `each'
  /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/railties-4.2.8/lib/rails/all.rb:11:in `<top (required)>'
  /var/www/discourse/config/application.rb:2:in `require'
  /var/www/discourse/config/application.rb:2:in `<top (required)>'
  /var/www/discourse/config/environment.rb:2:in `require'
  /var/www/discourse/config/environment.rb:2:in `<top (required)>'
  /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/pry-0.10.4/lib/pry/pry_class.rb:91:in `require'
  /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/pry-0.10.4/lib/pry/pry_class.rb:91:in `block in load_requires'
  /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/pry-0.10.4/lib/pry/pry_class.rb:90:in `each'
  /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/pry-0.10.4/lib/pry/pry_class.rb:90:in `load_requires'
  /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/pry-0.10.4/lib/pry/pry_class.rb:128:in `initial_session_setup'
  /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/pry-0.10.4/lib/pry/cli.rb:206:in `block in <top (required)>'
  /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/pry-0.10.4/lib/pry/cli.rb:83:in `block in parse_options'
  /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/pry-0.10.4/lib/pry/cli.rb:83:in `each'
  /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/pry-0.10.4/lib/pry/cli.rb:83:in `parse_options'
  /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/pry-0.10.4/bin/pry:16:in `<top (required)>'
  /var/www/discourse/vendor/bundle/ruby/2.4.0/bin/pry:22:in `load'
  /var/www/discourse/vendor/bundle/ruby/2.4.0/bin/pry:22:in `<top (required)>'

That seems strange. Is your site up?

Yes it is, installed discourse today on a fresh vps after not having used it for quite some time :slight_smile:

Perhaps try rebuilding? I thought it might be something with Ruby 2.4, but I just did a clean install and rails c comes up just fine.

You followed the INSTALL-cloud instructions and Docker, right?

1 Like

ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]

Rails 4.2.8

Discourse v1.9.0.beta1 +79 installed yesterday using the guide and Docker.

Guys, can anyone shed light on coding a simple badge auto award so we can get it to site owner to upload since admins can’t.

We want it that when a user is added to a specific group, it awards a custom badge.

That’s all.

If user1 is added to groupX, award badgeX

SELECT gu.user_id, gu.created_at AS granted_at, null AS post_id
FROM group_users AS gu
WHERE gu.group_id = ( SELECT id FROM groups WHERE name ilike 'InsertTheTeamNameHere' )

Trigger daily

For reference:

6 Likes

@Trash, I had posted in another thread, and someone responded almost at the same time. The code is slightly different. Do you know what the difference would be?

main difference is: gu. vs g.

Other poster’s code:

select user_id, created_at granted_at, NULL post_id
from group_users
where group_id = (
  select g.id from groups g where g.name = 'your_group_name'
)

is there any practical difference?
I’m a complete novice at this, and I just want to give the site owner the code to copy/paste so he doesn’t have to modify it at all.

btw, the group name we are using is: Confirmed_ST_User

If you mean here:

select g.id from groups g where g.name = 'your_group_name'

that “groups g” means "from now on, when I say “g” I mean “groups”, so if the other one is “groups gu” and then it has gu instead of g, then it’s the same. I prefer the SQL syntax .... from groups as g, which I think is much clearer, but I don’t see it used in Discourse code much. (Probably just code I’ve submitted. :slight_smile:)

4 Likes

@team who do we email to get SQL badge triggering turned on for our site. I was unable to send @team a private message.

1 Like

You need to email team@discourse.org. (I’ll PM you directly).

@sam, can you set the enable_badge_sql setting by using environment variables? I tried doing it and it did not work.

Not at the moment, it is not shadowed by global.

Is there a particular reason you need this via env, presumably you only need to change it once.

If I understand correctly, it’s not possible to create a badge that is automatically given to members of a group without turning this SQL editing back on, correct?

That is correct. You’d either have to enable badge sql editing, or hook up something via the API to grant such badges.

1 Like

Is this a fairly common badge scenario? Any chance this will get built in?

I ask because I’d rather just be able to turn this on for several groups rather than ask my hosting co to enable a dangerous feature that I then have to use carefully.

This is my use-case:

Possibly, but badges don’t support custom parameters at this time, so you’d need to have badge SQL editing enabled to customize the specific group for the badge making it not feasible at this time.

If this is something you’d want to use, I’d recommend asking that it be enabled, add, modify, and test the query, and then request that it be disabled again.

2 Likes