I have no opinion on how to weigh things.
However, why not just add a popularity column to your location table? Suddenly your SQL query is incredibly simple.
The hard part, of course, is figuring out how and when to update this value. But since you save all activity data, you can always restore popularity values โโfrom journal entries.
This way you get good quick queries for the โmost popularโ locations, and if you want to change the way you calculate popularity, you can do so on your own.
If you are smart, you can develop a simple enough formula so that popularity can be tracked in real time. For example, if we are only interested in average ratings, you can change the average rating with just three variables: the current average rating, the number of object ratings and the new rating value.
Of course, things get more complicated when you start mixing how many times an object has been viewed, viewed, loved, etc .... but you may find that you can develop a method that is computationally cheap enough so that you can update the overall value popularity for almost every action.
source share