зеркало из https://github.com/mozilla/gecko-dev.git
Bug 418739 - The same invalid and old frecencies keep getting updated over and over again. b=417810, r=dietrich, b-ff3=beltzner
This commit is contained in:
Родитель
4233228a40
Коммит
ba2a87b83c
|
@ -1036,22 +1036,28 @@ nsNavHistory::InitStatements()
|
||||||
// Note, we are not limiting ourselves to places with visits
|
// Note, we are not limiting ourselves to places with visits
|
||||||
// because we may not have any if the place is a bookmark and
|
// because we may not have any if the place is a bookmark and
|
||||||
// we expired or deleted all the visits.
|
// we expired or deleted all the visits.
|
||||||
// we sort by visit count (even though it might not be correct
|
// We get two sets of places that are 1) most visited and 2) random so that
|
||||||
// as those visits could have been removed or expired.)
|
// we don't get stuck recalculating frecencies that end up being -1 every
|
||||||
|
// time
|
||||||
rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
|
rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
|
||||||
"SELECT id, visit_count, hidden, typed, frecency, url "
|
"SELECT id, visit_count, hidden, typed, frecency, url "
|
||||||
"FROM moz_places WHERE frecency = -1 "
|
"FROM ("
|
||||||
"ORDER BY visit_count DESC LIMIT ?1"),
|
"SELECT * FROM ("
|
||||||
|
"SELECT * FROM moz_places WHERE frecency = -1 "
|
||||||
|
"ORDER BY visit_count DESC LIMIT ROUND(?1 / 2)) "
|
||||||
|
"UNION "
|
||||||
|
"SELECT * FROM ("
|
||||||
|
"SELECT * FROM moz_places WHERE frecency = -1 "
|
||||||
|
"ORDER BY RANDOM() LIMIT ROUND(?1 / 2)))"),
|
||||||
getter_AddRefs(mDBInvalidFrecencies));
|
getter_AddRefs(mDBInvalidFrecencies));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// this query is designed to find places with high frecency and
|
// This query finds random old places to update frecency because frequently
|
||||||
// an "old" max visit_date.
|
// visited places will have their frecencies updated when visited
|
||||||
rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
|
rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
|
||||||
"SELECT h.id, h.visit_count, h.hidden, h.typed, h.frecency, h.url "
|
"SELECT id, visit_count, hidden, typed, frecency, url "
|
||||||
"FROM moz_places h WHERE "
|
"FROM moz_places "
|
||||||
SQL_STR_FRAGMENT_MAX_VISIT_DATE( "h.id" )
|
"ORDER BY RANDOM() LIMIT ?1"),
|
||||||
" < ?1 ORDER BY h.frecency DESC LIMIT ?2"),
|
|
||||||
getter_AddRefs(mDBOldFrecencies));
|
getter_AddRefs(mDBOldFrecencies));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
@ -6113,36 +6119,22 @@ nsNavHistory::RecalculateFrecencies(PRInt32 aCount, PRBool aRecalcOld)
|
||||||
{
|
{
|
||||||
mozStorageTransaction transaction(mDBConn, PR_TRUE);
|
mozStorageTransaction transaction(mDBConn, PR_TRUE);
|
||||||
|
|
||||||
nsresult rv = RecalculateFrecenciesInternal(mDBInvalidFrecencies, -1, aCount);
|
nsresult rv = RecalculateFrecenciesInternal(mDBInvalidFrecencies, aCount);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
if (aRecalcOld) {
|
if (aRecalcOld) {
|
||||||
// if the last visit date was "recent" (in the top bucket)
|
rv = RecalculateFrecenciesInternal(mDBOldFrecencies, aCount);
|
||||||
// don't bother recalculating as it was recalculated recently
|
|
||||||
// and we are looking for "older" places.
|
|
||||||
PRTime startOfFirstBucket = GetNow() -
|
|
||||||
(USECS_PER_DAY * (mFirstBucketCutoffInDays + 1));
|
|
||||||
|
|
||||||
rv = RecalculateFrecenciesInternal(mDBOldFrecencies, startOfFirstBucket, aCount);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsNavHistory::RecalculateFrecenciesInternal(mozIStorageStatement *aStatement, PRInt64 aBindParameter, PRInt32 aCount)
|
nsNavHistory::RecalculateFrecenciesInternal(mozIStorageStatement *aStatement, PRInt32 aCount)
|
||||||
{
|
{
|
||||||
nsresult rv;
|
|
||||||
|
|
||||||
mozStorageStatementScoper scoper(aStatement);
|
mozStorageStatementScoper scoper(aStatement);
|
||||||
PRInt32 countBindIndex = 0;
|
|
||||||
if (aBindParameter != -1) {
|
|
||||||
rv = aStatement->BindInt64Parameter(0, aBindParameter);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
countBindIndex = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
rv = aStatement->BindInt32Parameter(countBindIndex, aCount);
|
nsresult rv = aStatement->BindInt32Parameter(0, aCount);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
PRBool hasMore = PR_FALSE;
|
PRBool hasMore = PR_FALSE;
|
||||||
|
|
|
@ -415,7 +415,7 @@ protected:
|
||||||
* Indicates that we should update old visits as well.
|
* Indicates that we should update old visits as well.
|
||||||
*/
|
*/
|
||||||
nsresult RecalculateFrecencies(PRInt32 aCount, PRBool aRecalcOld);
|
nsresult RecalculateFrecencies(PRInt32 aCount, PRBool aRecalcOld);
|
||||||
nsresult RecalculateFrecenciesInternal(mozIStorageStatement *aStatement, PRInt64 aBindParameter, PRInt32 aCount);
|
nsresult RecalculateFrecenciesInternal(mozIStorageStatement *aStatement, PRInt32 aCount);
|
||||||
|
|
||||||
nsresult CalculateFrecency(PRInt64 aPageID, PRInt32 aTyped, PRInt32 aVisitCount, nsCAutoString &aURL, PRInt32 *aFrecency);
|
nsresult CalculateFrecency(PRInt64 aPageID, PRInt32 aTyped, PRInt32 aVisitCount, nsCAutoString &aURL, PRInt32 *aFrecency);
|
||||||
nsresult CalculateFrecencyInternal(PRInt64 aPageID, PRInt32 aTyped, PRInt32 aVisitCount, PRBool aIsBookmarked, PRInt32 *aFrecency);
|
nsresult CalculateFrecencyInternal(PRInt64 aPageID, PRInt32 aTyped, PRInt32 aVisitCount, PRBool aIsBookmarked, PRInt32 *aFrecency);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче