Popular PhotoThe Pinkbike photo page recently got a new addition in form of a Popular Photo box right above the previous favorites and mobile uploads boxes.
The Popular Photos area is a personalized photo section that shows photos that you have not seen yet, but your friends have. It's organized to show the most popular first.
On Pinkbike there are tons of great pictures being uploaded every day, yet you don't always get a chance to see them all. The Pinkbike photo page has a lot of options that make viewing and searching for photos really easy, but the amount of content being uploaded is big enough so that some of those masterpieces might go unnoticed. To solve this, Pinkbike started to develop a popular section in order to present you the best photos that were most popular within a given period of time. Can't wait any longer to check out this new addition? Go ahead and hit the “View more popular photos” button to see the
page. If you want some insight into this system just keep reading.
This is a view of the popular page. Marked in red there are tabs that you can switch between to get a different set of photos. There are two main categories of popular photos. The first one contains all photos that were most popular among users you follow. The main goal of this category is to present you content that best suits best personal preferences. Based on whether you follow users from your neighbourhood or best photographers on Pinkbike you will get photos from your local events and contents or the latest photos from the biggest events in the world.
The second category contains all photos that were most popular among all Pinkbike users. This category is not about personal preferences, but about the absolute best possible photos. If you keep up with this one you can be sure that none of those great shots will miss you!
In both categories you can choose from photos being most popular during last day or during last week. A history tab will keep track of the photos you have already seen, which is very useful in terms of what you will read next.
How Does it Work?The rules are pretty simple. Let's take the “Friends Weekly” tab as an example. The more views and favs a given photo received from users you follow during the last week, the most popular it is. And in each tab photos are presented in descending order from the most popular to the least popular. But that is not all - each time you view some photo we will not bother you with it next time you visit this tab but instead propose some other photos that you have not seen yet! That is where the history tab comes in handy allowing you to get back to the photos you have already seen one more time.
Clockwise from top left corner: Friends weekly tab before viewing marked photo, History tab before viewing marked photo, History tab after viewing marked photo, Friends weekly tab after viewing marked photo.
Tech TalkFor those who find this system interesting enough we decided to prepare a little tech talk which can give you even more insight.
Pinkbike uses zeroMQ extensively as a messaging library. 100s of zeroMQ messages per page view corresponding to all sorts of information are sent to a message broker. The Photo Popular system uses these messages and is also based on Redis, which for our purpose is great because it allows us to store information in simple key value pattern using sets or sorted sets and allows us to perform operations on those keys like union, diff or expiration.
Certain Python scripts are responsible for catching certain actions like photo view or fav from Pinkbike site and updating corresponding keys in Redis database. Other Python scripts are responsible for filtering those actions first so as to make sure that every single action is unique. All information about viewed photos are stored per user per day of the week. All keys from the given day are overwritten after one week once the corresponding day starts. Some of this information is stored in additional keys so as to make things work faster, e.g. all photos viewed on Pinkbike daily. Basically there are few interesting tricks implemented that allow us to optimize this system in both time and space.
While proposing photos popular among all Pinkbike users is 'just' about diffing previously prepared set of photos with what you have seen, proposing photos popular among your friends is quite a bit more challenging. Based on how many users you follow, unioning all those sets can require a lot of computation for a one simple page load. This being the main challenge, we managed to plan Redis database so that it is actually possible to make all those computations during one page load as opposed to storing different additional sets of photos for different groups of friends.
Editor's NoteLukasz Rajzer - chajcu is a Pinkbike developer located in Krakow, Poland. He is an avid rider and DH racer in the Polish DH Cup on the
Bartbass Goodbike DH Team
www.pinkbike.com/photo/7273891
www.pinkbike.com/photo/9984441
If you don't hear from me tomorrow then the NSA backdoor is there!
Now, how about an update to the buy/sell that lets us save search criteria and get a notification when new listings match that criteria? Would be an awesome addition to PB.