Building board archiving and sorting – Pinterest Engineering – Medium


Connor Montgomery | Software engineer, Product Engineering

A Pinterest tradition we’ve had since our early days is the Make-a-thon, our twist on a hackathon. Make-a-thons bring together employees from different disciplines to build something new. In the past, we’ve had projects range from scaling hacks to AR prototypes to in-product features we actually ship, like GIF support and Tried It.

Our last Make-a-thon was at the end of 2017, with more than 50 ideas submitted and 30 projects finished in time for judging. We turned the company All Hands area into a “make space” where we concepted and developed projects over three days. My favorite part of the event was the judges, because for the first time we invited a group of Pinners to meet the teams, judge the projects and select the winners.

Last week we announced new tools to help Pinners organize their Pins and boards, and a few of these features actually started out as Make-a-thon projects! I wanted to highlight them in this post.

Board archiving

Before going in-depth on board archiving, I wanted to set a bit of context about a few challenges I (and others) have experienced with Pinterest.

A few years ago, my wife and I got married, and we (obviously) planned our wedding on Pinterest. It was such a great experience–we had 12 wedding-themed boards (if only we had sections at that time!) and were able to easily collaborate to plan the wedding of our dreams.

However, a few months after the wedding, I started to notice some issues:

  • Anytime I saved a Pin, I had to sift past all those wedding boards to find the one I was looking for.
  • Those 12 boards were still on my profile long after the wedding (even though I was no longer in “wedding mode”).
  • Since I had saved so many wedding Pins, Pinterest was still recommending me more wedding ideas long after we had gotten married.

I could have just deleted my boards, but I didn’t want to lose those Pins forever. I wasn’t alone in this experience, and there was a clear gap in the product that needed to be fixed for Pinners.

With such a clear problem, it was easy to scope out the product requirements:

  • Archiving a board should remove it from your boards list when you save a Pin.
  • Archiving a board should send negative signal to our system so we no longer make related recommendations and notifications.
  • Archiving a collaborative board shouldn’t interfere with how the other collaborators use that board.
  • Archived boards should live at the very bottom of the profile in their own section.
  • When viewing an archived board, we should be clear that you’ve archived it.

Data Storage

We used Zen, our graph storage system, to power the backend for board archiving. We built it in a very simple way–anytime a user archives a board, we add an edge from user ID<>board ID.

By default, Zen gives edges a score of the current epoch time in milliseconds. We use that score to show the time the board was archived when viewing an archived board page.

If a user un-archives a board, we simply remove the edge.

The added benefit of this userId<>boardId storage system is that it’s per user, per board. That means that it won’t impact other collaborators on group boards a user has archived.

Since Zen has built-in caching, it’s easy for us to filter archived boards out of a list of boards for a given user without having to worry about performance. We have the following function signature that filters a list of boards and only returns non-archived ones:

def filter_archived_boards(all_boards, user_id)

Under the hood, we simply check if an edge exists between the (user_id, board_id) tuples generated in that function. Zen supports bulk fetching, so we just need to make one call to the graph service. We then remove boards that are archived from the all_boards list and return the new list to the callers.

Negative Signal

The final requirement for archiving boards was to provide negative signal so Pinners would no longer see recommendations based on their archived boards in home feed, email or in-app notifications.

After some coordination with the teams that would consume the data as well as the team that owned the indexing pipeline, we agreed to put this data into BoardJoin, PinJoin and UserJoin. A couple of small data jobs were required to massage the data from Zen into the right format for integration into the Joins.

We passed the baton to engineers on the notifications and home feed recommendations teams once the data was propagated to the right places, and the final items required to launch this feature were soon complete.

Board sorting

It was clear from the Make-a-thon that Pinners were yearning for more organization power on their boards and profile, because the winning project of the Pinner’s Choice award was new ways to sort boards. In fact, the ability to rearrange boards alphabetically was one of the top three feature requests we received in 2017.

Despite the simplicity of the feature, it was more challenging to build than expected. The Make-a-thon got us to ~70 percent feature complete, but there were a few additional things we needed to consider to determine the expected behavior:

  • If a user changes their own board order, should this be reflected in their public profile?
  • How does this new sorting persist across all platforms?
  • Should a user be able to sort someone else’s boards when viewing their profile?
  • How does this affect users who’ve spent countless hours rearranging their boards in the pre-existing “drag and drop” method on web / that applied to web only?

After working with members from design, product and marketing, we agreed on the expected behavior and turned the above questions into more solidified product requirements:

  • The order a user selects for their personal profile should be reflected in their public view.
  • Once a user selects their preferred sorting order, this option should be reflected across all platforms (e.g. web, mobile).
  • Users shouldn’t lose access to their custom order if they’ve already rearranged boards via “drag and drop.”

One of the challenges in developing the feature in the backend and API layer was in identifying the right place to store a client-side UI state setting in a persistent and cross-platform manner. We wanted users to be able to set their own local override of the board sorting for their own profiles, and have that setting persist across devices. There were existing systems for user properties, but nothing for generic UI state settings. As part of this change, we created a new API to access content stored in the User Metadata Service via the REST API, so product engineers can move quicker for these kinds of requirements going forward.

Wrapping up

These are just a few of the projects that came out of our most recent Make-a-thon. As engineers, we’re always thinking of ways to improve Pinterest and make it more useful for our +200M monthly active Pinners. If you like building products people love, join us!

Acknowledgements: Board archiving and sorting were built in collaboration with Jean Yang, Bo Zhao, Grace Si, Koichiro Narita, Helen Fu, Connor Gall, Julia Cochran, Becky Stoneman, Jordan Adler, Joseph Zingarelli, Shira Netter and Kim O’ Rourke. Special thanks to Jean Yang, Julia Cochran and Jordan Adler for contributing to this post.



Source link