Last active
May 14, 2018 23:54
-
-
Save darktrojan/d5c399bf5d107176fbac to your computer and use it in GitHub Desktop.
Recalculate frecency score for all places
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var start = Date.now(); | |
var cutoff = (Date.now() - 180 * 86400000) * 1000; | |
var min_frecency = 50; | |
PlacesUtils.history.DBConnection.createAsyncStatement( | |
'UPDATE moz_places SET ' + | |
'visit_count = MAX((SELECT COUNT(*) FROM moz_historyvisits WHERE place_id = moz_places.id AND visit_date > ' + cutoff + '), 1) ' + | |
'WHERE frecency > ' + min_frecency | |
).executeAsync({ | |
handleCompletion: function() { | |
PlacesUtils.history.DBConnection.createAsyncStatement( | |
'UPDATE moz_places SET frecency = CALCULATE_FRECENCY(id) WHERE frecency > ' + min_frecency | |
).executeAsync({ | |
handleCompletion: function() { | |
NewTabUtils.links.populateCache(null, true); | |
let end = Date.now(); | |
alert('That took ' + (end - start) / 1000 + ' seconds'); | |
} | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment