What qualifies an application as frequently used?

Solution 1:

Basic answer

Simply put, the Most Frequently Used scope sorts applications by the number of times you've launched them. That is to say, if you've launched Firefox 1000 times, and Chromium 999 times, Firefox will be listed first. Even if you haven't launched Firefox in months and months.

Technical answer

Simply put, the Most Frequently Used scope is a wrapper that searches a Zeitgeist.Index of installed applications with a result type of MostPopularSubjects. Zeitgeist measures this popularity with the zeitgeist-datahub daemon, which notices and updates its statistics each time you launch an application. You can look at the relevant lens code here, and the API documentation for Zeitgeist here.

Having looked at the current Zeitgeist code, it appears MostPopularSubjects is a simple sort by number of accesses. Additionally, given the same number of application accesses, the applications are sorted by newest first. It's a little more complex than this, but the SQL generated for a Most Frequently Used request is more-or-less:

SELECT
  subj_id,
  MAX(timestamp) as timestamp,
  COUNT(subj_id) as num_events
FROM
  event_view
GROUP BY
  subj_id
ORDER BY
  num_events DESC
  timestamp DESC

Isn't open source beautiful?