Closed (won't fix)
Project:
Voting API
Version:
5.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
29 Mar 2007 at 13:29 UTC
Updated:
11 Jan 2011 at 16:26 UTC
See
http://www.webcodr.com/4/writing-a-digg-style-popularity-algorithm/
I'am not familiar with voting api today, but this algorithm looks fairly interesting.
I don't have the time, nor the knowledge to make this. But anyone who can, feel free to start hacking out a digg/reddit clone;)
eg. votingstyle is: Popularity = Votes / Record Age
But check out the link I provided to get a more in depth understanding.
Comments
Comment #1
stephencarr commentedWithout something like this I find that most of the modules that use voting API are kind of useless in terms of displaying popular content. We can pretty much only display which content has the most votes filtered by very ordinary things like time, user etc. etc. I am surprised less people are interested in a more algorithmic way of sorting nodes.
Comment #2
Scott Reynolds commentedThis algorithm has actually been implemented on http://www.momblognetwork.com
the code that does it is run at cron time and it is this:
Comment #3
stephencarr commentedHi Scott, good to hear that there is a way ahead. Could you maybe explain how this can be integrated with a generic site using the voting api? I am not really sure how I can get this code to run at cron and how I can take advantage of the data it saves, in other words how do I integrate it with a view generated or templated page?
Many thanks.
Comment #4
Scott Reynolds commentedCreate a module and call that function on its hook_cron.
Then votingapi will add the filter, arguments etc to views with a score title popularity. Votingapi takes care of all the views for you, just create a module that calculates the popularity score.
Comment #5
Scott Reynolds commentedand if that doesn't make sense to you use Drigg: http://drupal.org/project/drigg
Comment #6
stephencarr commentedThanks very much! I looked at Drigg a while back but for some reason passed it over. I think I will be having another look or perhaps try writing a module of my own and implementing your code, always willing to learn more.
Comment #7
stephencarr commentedThe function you listed above is missing the _popularity_user_weight() function definition, I'd be interested in how that works. Also I am not certain but isn't _votingapi_insert_cache_result() a private function of the votingapi and therefore not accessible from another module?
Comment #8
Scott Reynolds commentedyes it is missing that function, i forgot to take that line out. Sorry ;) thats our secret sauce. I should have replaced it with a 1.
as far as 'private' goes, there is no 'private' functions in drupal. They are written that way to indicate that they shouldn't be used by outside modules but clearly this is a instance where its needed.
You could, instead of calling that function, insert the record directly into the table.
Comment #9
eaton commentedSupport for the 5.x branch of VotingAPI has ended with the release of Drupal 7 and the upcoming release of VotingAPI 7.x-2.4.