-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How would you create weight related to time? #33
Comments
Hello, As the code to calculate weight is in Ruby rather than in the DB, this will be inherently slow for large DB tables. With that caveat, the formula we currently have for weighting: karma = sum(vote * weight), where weight is a fraction from [0,1]. If you want to weight newer items, then you'll want to change that formula to: karma = sum(vote * weight * vote[time_since_updated_at]) Another hint I'll give you are that these two lines of code are critical for what you want to achieve: https://github.com/brady8/thumbs_up/blob/master/lib/has_karma.rb#L16 |
How do you sort by karma? E.g... View the hottest "Questions" sorted by karma value? A question with 5 points yesterday would be below a vote with 5 points today, even possibly if that question had 6 points yesterday it'd still be below the 5 point from today... |
That would be a useful method to add to thumbs_up! I would encourage you to look at the source (most of it is quite straightforward), and I'll be happy to take a pull request from you if you come up with something that works. Sorry that I don't have time to code it up myself. |
I wish my back-end skills were up to chops. My speciality is front-end development. I'll give it a try though... |
If you look at this at a slightly higher/abstract level, sorting by karma would be sorting based on a calc based on database query. I had a similar challenge and asked the following question on SO: When I saw the query that DGM provided in that answer it reminded me that a while back I had also had wanted to sort by karma. Applying the last part of DGM's answer, a karma sort on a votable Post model might be something like:
I looked into this, but it was quickly obvious that I don't have the technical chops to figure out how to implement the 'sum(vote*weight)' calculation in a DB call, but hopefully someone else might. |
Hi,
I have interest in adding something that adds more weight the newer the submission is. Otherwise only old entries will be at the top. Does anyone know how to do this?
The text was updated successfully, but these errors were encountered: