This document provides specific details on how the popularity widget works Widgets: Frequently Asked Questions. From the document, I did want to highlight that there is a PopularityDeterminationTask which determines the popularity:
PopularityDeterminationTask is the class that handles the majority of the work. It runs every 15 minutes (as configured in spring-taskContext.xml, and works closely with ActivityManagerImpl.
Hope this helps.