зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1719199 - Add scrolling metrics to history metadata tables in places db r=mak
We need to first add the scrolling metrics (scrolling_time and scrolling_distance) to the DB so we can complete the capturing and tests for those metrics (see Bug 1717920) Differential Revision: https://phabricator.services.mozilla.com/D119119
This commit is contained in:
Родитель
8271e2f9ca
Коммит
1347e6dc17
|
@ -108,6 +108,10 @@ class TypingInteraction {
|
|||
* Time in milliseconds that the user typed on the page
|
||||
* @property {number} keypresses
|
||||
* The number of keypresses made on the page
|
||||
* @property {number} scrollingTime
|
||||
* Time in milliseconds that the user spent scrolling the page
|
||||
* @property {number} scrollingDistance
|
||||
* The distance, in pixels, that the user scrolled the page
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -256,6 +260,8 @@ class _Interactions {
|
|||
totalViewTime: 0,
|
||||
typingTime: 0,
|
||||
keypresses: 0,
|
||||
scrollingTime: 0,
|
||||
scrollingDistance: 0,
|
||||
created_at: now,
|
||||
updated_at: now,
|
||||
};
|
||||
|
@ -609,6 +615,10 @@ class InteractionsStore {
|
|||
Math.round(interaction.totalViewTime) || 0;
|
||||
params[`typing_time${i}`] = Math.round(interaction.typingTime) || 0;
|
||||
params[`key_presses${i}`] = interaction.keypresses || 0;
|
||||
params[`scrolling_time${i}`] =
|
||||
Math.round(interaction.scrollingTime) || 0;
|
||||
params[`scrolling_distance${i}`] =
|
||||
Math.round(interaction.scrollingDistance) || 0;
|
||||
SQLInsertFragments.push(`(
|
||||
(SELECT id FROM moz_places_metadata
|
||||
WHERE place_id = (SELECT id FROM moz_places WHERE url_hash = hash(:url${i}) AND url = :url${i})
|
||||
|
@ -618,7 +628,9 @@ class InteractionsStore {
|
|||
:updated_at${i},
|
||||
:total_view_time${i},
|
||||
:typing_time${i},
|
||||
:key_presses${i}
|
||||
:key_presses${i},
|
||||
:scrolling_time${i},
|
||||
:scrolling_distance${i}
|
||||
)`);
|
||||
i++;
|
||||
}
|
||||
|
@ -630,11 +642,11 @@ class InteractionsStore {
|
|||
async db => {
|
||||
await db.executeCached(
|
||||
`
|
||||
WITH inserts (id, place_id, created_at, updated_at, total_view_time, typing_time, key_presses) AS (
|
||||
WITH inserts (id, place_id, created_at, updated_at, total_view_time, typing_time, key_presses, scrolling_time, scrolling_distance) AS (
|
||||
VALUES ${SQLInsertFragments.join(", ")}
|
||||
)
|
||||
INSERT OR REPLACE INTO moz_places_metadata (
|
||||
id, place_id, created_at, updated_at, total_view_time, typing_time, key_presses
|
||||
id, place_id, created_at, updated_at, total_view_time, typing_time, key_presses, scrolling_time, scrolling_distance
|
||||
) SELECT * FROM inserts WHERE place_id NOT NULL;
|
||||
`,
|
||||
params
|
||||
|
|
|
@ -1189,7 +1189,12 @@ nsresult Database::InitSchema(bool* aDatabaseMigrated) {
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
// Firefox 91 uses schema version 56
|
||||
if (currentSchemaVersion < 57) {
|
||||
rv = MigrateV57Up();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
// Firefox 91 uses schema version 57
|
||||
|
||||
// Schema Upgrades must add migration code here.
|
||||
// >>> IMPORTANT! <<<
|
||||
|
@ -2204,6 +2209,31 @@ nsresult Database::MigrateV56Up() {
|
|||
CREATE_IDX_MOZ_PLACES_METADATA_PLACECREATED);
|
||||
}
|
||||
|
||||
nsresult Database::MigrateV57Up() {
|
||||
// Add the scrolling columns to the metadata.
|
||||
nsCOMPtr<mozIStorageStatement> stmt;
|
||||
nsresult rv = mMainConn->CreateStatement(
|
||||
"SELECT scrolling_time FROM moz_places_metadata"_ns,
|
||||
getter_AddRefs(stmt));
|
||||
if (NS_FAILED(rv)) {
|
||||
rv = mMainConn->ExecuteSimpleSQL(
|
||||
"ALTER TABLE moz_places_metadata "
|
||||
"ADD COLUMN scrolling_time INTEGER NOT NULL DEFAULT 0 "_ns);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
rv = mMainConn->CreateStatement(
|
||||
"SELECT scrolling_distance FROM moz_places_metadata"_ns,
|
||||
getter_AddRefs(stmt));
|
||||
if (NS_FAILED(rv)) {
|
||||
rv = mMainConn->ExecuteSimpleSQL(
|
||||
"ALTER TABLE moz_places_metadata "
|
||||
"ADD COLUMN scrolling_distance INTEGER NOT NULL DEFAULT 0 "_ns);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult Database::ConvertOldStyleQuery(nsCString& aURL) {
|
||||
AutoTArray<QueryKeyValuePair, 8> tokens;
|
||||
nsresult rv = TokenizeQueryString(aURL, &tokens);
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
// This is the schema version. Update it at any schema change and add a
|
||||
// corresponding migrateVxx method below.
|
||||
#define DATABASE_SCHEMA_VERSION 56
|
||||
#define DATABASE_SCHEMA_VERSION 57
|
||||
|
||||
// Fired after Places inited.
|
||||
#define TOPIC_PLACES_INIT_COMPLETE "places-init-complete"
|
||||
|
@ -329,6 +329,7 @@ class Database final : public nsIObserver, public nsSupportsWeakReference {
|
|||
nsresult MigrateV54Up();
|
||||
nsresult MigrateV55Up();
|
||||
nsresult MigrateV56Up();
|
||||
nsresult MigrateV57Up();
|
||||
|
||||
void MigrateV52OriginFrecencies();
|
||||
|
||||
|
|
|
@ -286,6 +286,8 @@
|
|||
"total_view_time INTEGER NOT NULL DEFAULT 0, " \
|
||||
"typing_time INTEGER NOT NULL DEFAULT 0, " \
|
||||
"key_presses INTEGER NOT NULL DEFAULT 0, " \
|
||||
"scrolling_time INTEGER NOT NULL DEFAULT 0, " \
|
||||
"scrolling_distance INTEGER NOT NULL DEFAULT 0, " \
|
||||
"document_type INTEGER NOT NULL DEFAULT 0, " \
|
||||
"search_query_id INTEGER, " \
|
||||
"FOREIGN KEY (place_id) REFERENCES moz_places(id) ON DELETE CASCADE, " \
|
||||
|
|
|
@ -15,7 +15,7 @@ var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
|||
|
||||
// Put any other stuff relative to this test folder below.
|
||||
|
||||
const CURRENT_SCHEMA_VERSION = 56;
|
||||
const CURRENT_SCHEMA_VERSION = 57;
|
||||
const FIRST_UPGRADABLE_SCHEMA_VERSION = 43;
|
||||
|
||||
async function assertAnnotationsRemoved(db, expectedAnnos) {
|
||||
|
|
Двоичный файл не отображается.
|
@ -23,3 +23,10 @@ add_task(async function database_is_valid() {
|
|||
)[0].getResultByIndex(0);
|
||||
Assert.equal(count, 0, "Empty table");
|
||||
});
|
||||
|
||||
add_task(async function scrolling_fields_in_database() {
|
||||
let db = await PlacesUtils.promiseDBConnection();
|
||||
await db.execute(
|
||||
`SELECT scrolling_time,scrolling_distance FROM moz_places_metadata`
|
||||
);
|
||||
});
|
||||
|
|
|
@ -6,7 +6,7 @@ support-files =
|
|||
places_outdated.sqlite
|
||||
places_v43.sqlite
|
||||
places_v54.sqlite
|
||||
places_v56.sqlite
|
||||
places_v57.sqlite
|
||||
|
||||
[test_current_from_downgraded.js]
|
||||
[test_current_from_outdated.js]
|
||||
|
|
Загрузка…
Ссылка в новой задаче