Popularity, How to make new hits count more than old hits?

Mithil

New Member
Each product a \[code\]product_date_added\[/code\] which is a \[code\]Date\[/code\] field contained the date it was added.They also have a \[code\]product_views\[/code\] which is an \[code\]int\[/code\] field containing how many times a product has been viewed.To display products by popularity, I us an algorithm to calculate how many hits per day a product has. \[code\]SELECT AVG(product_views / DATEDIFF(NOW(), product_date_added)) as avg_hits , product_table.* FROM product_tableWHERE product_available = "yes" GROUP BY product_idORDER BY avg_hits DESC\[/code\]This works, but the boss is noticing a lot of older products showing up first. So he basically wants newer views to have more weight than older views. His suggestion was that any views over a year old don't count. I think I would have to keep a date of every view in order to do that, which I think would slow down performance. What is the best way to create a popularity algorithm like what my boss is asking for? Ideally I would want to be able to come up with something that doesn't alter the table structure. If that is not possible, I would at least like to come up with a solution that can use the existing data so we are not starting from 0. If thats not possible either than anything that will work.
 
Back
Top