Invite badges from inviting yourself

They are indeed system badges, and can’t be edited by the UI (though they are visible). That line would need to be added with a PR. :+1:

3 Likes

Mind if I try and make that PR. I think I just need to change the SQL in discourse/lib/badge_queries.rb lines 156-167

3 Likes

Hello. After my badges were removed one day ago, they suddenly came back. Can someone fix this issue?

1 Like

They will come back as the queries run daily and you still ‘qualify’. :slight_smile: We would have to remove them manually every day until the bug gets fixed, which is unrealistic.

I have checked, and we can make this pr-welcome :+1: (You would need to do all three)

4 Likes

Got it Thanks. I should be able to do this

And I don’t see why I would need to do 3. The one for invite links is a function with returns the count if I read the function correctly.

3 Likes

I did not look at the code, so you may be right. :slightly_smiling_face:

3 Likes
  def self.invite_badge(count, trust_level)
    <<~SQL
      SELECT u.id user_id, current_timestamp granted_at
      FROM users u
      WHERE u.id IN (
        SELECT invited_by_id
        FROM invites i
        JOIN invited_users iu ON iu.invite_id = i.id
        JOIN users u2 ON u2.id = iu.user_id
        WHERE i.deleted_at IS NULL AND u2.active AND u2.trust_level >= #{trust_level.to_i} AND u2.silenced_till IS NULL
        GROUP BY invited_by_id
        HAVING COUNT(*) >= #{count.to_i}
      ) AND u.active AND u.silenced_till IS NULL AND u.id > 0 AND
        (:backfill OR u.id IN (:user_ids) )
    SQL
  end

Here it is. Seems like its just the 1. And looked through the whole file and nothing else with invites


Made the PR

5 Likes

Looking at the PR (and bear in mind that PRs aren’t my forte), it looks like you’ve hardcoded it to be just the Promoter version by changing the #{count.to_i} to be 1?

My example above was only a proof of concept, and would need to be adapted to suit. :+1:

(also, looking at the text in that onebox, I’m ‘JammyDodger’ not ‘Jammy Dogger’… :slight_smile:)

8 Likes

My bad. Fixed your name

4 Likes

Thank you for your contribution! I’ve merged your PR

Also, a super small note that we typically require tests for modifications, but seeing there was none before we’ll just merge this and backfill.

Hope to see more from you in the future :hugs:

8 Likes

This topic was automatically closed after 2 days. New replies are no longer allowed.