Jump to content

SOLVED Sorting by computed value


thomas
 Share

Recommended Posts

Hello,

is there a way to sort pages by a computed value other than using raw MySQL? I have about 2000 pages which all have a "views" field. Now I'd like to sort them by "views per day", so calculate the age of the post in days and divide the views by the age. I thought about a LazyCron which computes this value every now and then and writes them into a field but this would mean the value is always outdated and I'm not sure how long the cron would take on a large number of pages ...

Has anyone got any suggestions on how to do this?

Thanks,

thomas

Solved. Sorry. Next time I think before I post

I now update the "views per day" value every time the "views" value is updated. This is of course a bit inaccurate since the views might not get updated for a couple of days but I figured that's a small price to pay for not having a cron iterate over the pages every so often.

Edited by thomas
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...