Jump to content

Sorting based on votes over time? Algorhythmic sorting?


Edward Cufaude
 Share

Recommended Posts

I'd just like to ask how you guys would you go about this, as I'm not sure whether my proposed solution is the easiest method of achieving this.

I have a basic voting system setup and an integer field on each page which increments every time someone votes on something, I also store the pages voted on in each user, I can then sort pages by number of votes, and also display to the user a list of pages voted on. So far it is working good.

Now I'm looking at creating a list of sorted pages that is more dynamic. So something like the number of votes divided by number of days since the page was published, so a newer page with 10 votes on in 1 day (10 votes per day) will come above the page that has 12 votes over 2 days (6 per day) because although 10 votes is less than 12, the number of votes over time is greater so therefore it comes out higher. Basically something similar to how sites like reddit do their sorting as it is more dynamic based on users, but items can drop off if popularity doesn't keep up.

My thoughts are that you could have a separate field on each page, which is number of votes divided by time since published for each page which is updated when a vote is placed and say every hour using a script in a cron job, so pages without new votes also get updated. But I'm not sure whether that is the right thing to do as I'm not sure whether updating multiple pages at regular intervals is a good idea if the number of pages gets large and wanted thoughts on whether this could be done a simpler way.  

 
Link to comment
Share on other sites

An immediate random thought is visits/votes rather than age/votes. You could update this on each visit (or vote) and not need a cron job.

So a page with 50 visits and 20 votes (2.5 visits to gain each vote) is better rated than a page with 5000 visits and 1500 votes (3.333 visits per vote). Lower scores are better.

Link to comment
Share on other sites

Anything, which is dependent on the time should not be stored anywhere, as it's potentially invalid minutes later. Calculating these at runtime is easy, but for db selection you'd need to build a custom selector or completely switch to raw mysql queries. 

  • Like 1
Link to comment
Share on other sites

An immediate random thought is visits/votes rather than age/votes. You could update this on each visit (or vote) and not need a cron job.

So a page with 50 visits and 20 votes (2.5 visits to gain each vote) is better rated than a page with 5000 visits and 1500 votes (3.333 visits per vote). Lower scores are better.

That's an interesting idea on a way to achieve it, the first thing that comes to mind is whether that is fast. I'm looking at thousands of page visits a day and thinking that's a lot of extra writes to the database.

Link to comment
Share on other sites

Anything, which is dependent on the time should not be stored anywhere, as it's potentially invalid minutes later. Calculating these at runtime is easy, but for db selection you'd need to build a custom selector or completely switch to raw mysql queries. 

I'm already building custom selectors for this page. This is what I have at moment, it sorts by -numberwatchers (this is my votes field) and then by -published in case number watchers is same.

$results = $pages->find("template=contest, contest_closing_date>$currenttime, limit=6, sort=-numberwatchers, sort=-published");

Is it possible to do it in a selector? or do you have to do something along the lines of load every page, do the calculation on every page and then select from an array of pages to do it at runtime?

Link to comment
Share on other sites

If that's enough for you that's fine, but you wont get far if you want to select by "ratingOverTime>300", which is the dynamic number after your calculations. These would have to be custom selector implementations (extending the selector parsing / page loading, not just a custom selector string) or raw mysql queries.

Link to comment
Share on other sites

If that's enough for you that's fine, but you wont get far if you want to select by "ratingOverTime>300", which is the dynamic number after your calculations. These would have to be custom selector implementations (extending the selector parsing / page loading, not just a custom selector string) or raw mysql queries.

Thanks for reply, I will go investigate extending selector parsings and possibilities that open up if using raw mysql queries.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...