Badge notifications not being sent for newly created badges that are retroactive?

Having a look at my badges here on meta…
… there are some here I don’t believe I have never received a notification for.

I thought the whole idea for badges was to enforce good behaviour so would think I would get notifications.

The ones highlighted I really can’t remember receiving ever, there are others too - but these are ones these can be quite sure of.

I can’t see any badge notifications - in my notifications - but I’m not sure I should see them there:

4 Likes

Anniversary was just changed to silver so new installs will get it, there is some notification suppression logic see:

https://github.com/discourse/discourse/blob/master/app/services/badge_granter.rb#L288

So its legit that you are not being notified for that.

The sharing badge may need a tweak, its grabbing min(id) instead of max which means it is unlikely to hit the threshold

    SELECT views.user_id, i2.post_id, i2.created_at granted_at
    FROM
    (
      SELECT i.user_id, MIN(i.id) i_id
      FROM incoming_links i
      JOIN badge_posts p on p.id = i.post_id
      WHERE i.user_id IS NOT NULL
      GROUP BY i.user_id,i.post_id
      HAVING COUNT(*) > 25
    ) as views
    JOIN incoming_links i2 ON i2.id = views.i_id

How will the Anniversary Badge be handled for forums that are 11+ years old?
11 notifications the first time the badge runs?

at the moment its a once off badge, eventually we want to get a badge ber year but the query needs some careful planning

1 Like

One possibility would be to add another return column to the badge queries, call it repeat_id. Could be trivially mapped to the seq column in the badge_users table. Then have repeat_id * TIMESPAN('1 year') somewhere in the query.

my concern is around the 1 post per year req check, for each user you need to break it down to an artificial set with year-start / year-end and then join to that. it can get to be an expensive query.

Just checking out badges again…

I feel like I’ve missed some notifications here again…

If you compare the following graphic with the one in my first post - I don’t believe I have received notifications for the red arrowed ones:

1 Like

That’s probably because they’re bronze badges, and they got backdated past the notification cutoff date… we should either nix that notification cutoff or fix the badges

5 Likes

Not sure about that, it will probably end up being notification central if we do that.

We need a proper strategy of dealing with badge floods before doing any of that.

Again just to mention I don’t believe I received notifications for the following:

  • 20 Nice Share badges
  • 3 popular link badges

(I might have received notifications for 1 or 2 - but not 20+)

More recently I have been receiving notifications for new “Bug Reporter” badges.

Again, the granted_at field for those badges is broken… they are “awarded” “on” the date of the post, not the date of the Nth share.

3 Likes

“broken” - thanks for the clarification - this I understand.

Technically Nth share is a nightmare wrapped in 3 other nightmares to calculate, but we could simple set granted at for these badges to “now”

Fixed per:

https://github.com/discourse/discourse/commit/14a77aa1e0a0dec1ed378173cf4e5793f052857e

3 Likes