Bug 704977 - (Part 2) Awesomeness calculation should use nicer recency decay. r=lucasr

This commit is contained in:
Margaret Leibovic 2012-03-16 11:36:34 -07:00
Родитель cd371e0427
Коммит 497493f74b
1 изменённых файлов: 8 добавлений и 5 удалений

Просмотреть файл

@ -135,11 +135,14 @@ public class LocalBrowserDB implements BrowserDB.BrowserDBIface {
selectionArgs = DBUtils.appendSelectionArgs(selectionArgs, new String[] { urlFilter.toString() });
}
// ORDER BY is number of visits times a multiplier from 1 - 120 of how recently the site
// was accessed with a site accessed today getting 120 and a site accessed 119 or more
// days ago getting 1
final String sortOrder = History.VISITS + " * MAX(1, (" +
History.DATE_LAST_VISITED + " - " + System.currentTimeMillis() + ") / 86400000 + 120) DESC";
// Our version of frecency is computed by scaling the number of visits by a multiplier
// that approximates Gaussian decay, based on how long ago the entry was last visited.
// Since we're limited by the math we can do with sqlite, we're calculating this
// approximation using the Cauchy distribution: multiplier = 15^2 / (age^2 + 15^2).
// Using 15 as our scale parameter, we get a constant 15^2 = 225. Following this math,
// frecencyScore = numVisits * max(1, 100 * 225 / (age*age + 225)). (See bug 704977)
final String age = "(" + History.DATE_LAST_VISITED + " - " + System.currentTimeMillis() + ") / 86400000";
final String sortOrder = History.VISITS + " * MAX(1, 100 * 225 / (" + age + "*" + age + " + 225)) DESC";
Cursor c = cr.query(historyUriWithLimit(limit),
projection,