Discourse and the "can't give more likes" message

I can’t believe you’re digging into the source code for this :slight_smile:

My theory would be the first like/post/login of the calendar day starts your count, then you have 24 hours (which is why I noticed a badge at 6am the next day, about 24 since I started checking the forum on Saturday morning)

No, not that much. But sometimes you guys are writing one great post after another - and I would like to honor that with a “like”. If I like a post I would like to show that with a like. And I don’t exceed my like quota every day. :slight_smile: Beside that:

2 Likes

I’m a computer scientist. I like to know how things and especially software work. :slight_smile:

Same here - but when does the calendar day starts? :slight_smile: If the calendar day starts at midnight German time, then why Discourse shows me the warning message? I haven’t liked that much posts and how does Discourse know that I’m living in Germany? I haven’t told him that.

1 Like

I would guess server time for wherever discourse is hosted.

That leads us to my question in the first post. :wink:

1 Like

Because:

  • the post made me laugh
  • I agree with the post contents
  • the post contains positive thoughts
  • pictures, videos, sounds in the post are worth a mention (and a like)
  • I want to answer “Yes” if the post contains a question towards me
6 Likes

Not sure, but it could be a sliding 24 hour window. So you can only give 50 likes over 24 hours.

Well, we all knew! And even if Discourse didn’t, it does so know.
Isn’t that right?
@discobot fortune

1 Like

:crystal_ball: Don’t count on it

Don’t try and fool us by playing dumb…
@discobot fortune

1 Like

:crystal_ball: Yes

2 Likes

How else are you supposed to find such information? The code is the only accurate documentation!

The key is built dynamically: limit_exceeded.rb

It seems to use sliding expiration: rate_limiter.rb

2 Likes

Good point, Ron, er… I mean “Nor” :wink:

1 Like

Then this window has to start at some point. When is this? The first time I set a like?

But it’s Ruby code. :wink:

Can you point me to the code where the RateLimiter is used to check the Likes?

Just whenever you like now it can check how much likes are less than 24h ago.
something like:
If press_like then update_nr_of_likes_since(now-24hours)
if nr_likes_in_last24h > 50 then print “you spend way too much time liking stuff here”

Ah, Ok, right, now I got it. :slight_smile:

1 Like

Here the rate limiter checks the range: rate_limiter.rb#L68: if ((tonumber(redis.call("LLEN", key)) < max) or (now - tonumber(redis.call("LRANGE", key, -1, -1)[1])) > secs) then

Here are the rate limiters created: post_action.rb#L392 (note: there is a special case for likes involving a multiplier)

This looks… inefficient. :wink:

2 Likes

Great! Thanks!

1 Like

It was only for educational purposes :slight_smile:

1 Like

Edit: oh wow, under an hour it becomes specific: