Bug 2034513 Comment 3 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

Hi wayfaringbob, what would be helpful for me is for you to show some details that allow me to understand what is happening in your use case as it might reveal a gap in the algorithm. 

Please enable the [Browser Toolbox](https://firefox-source-docs.mozilla.org/devtools-user/browser_toolbox/) so that we can paste a script to get information about your database. If you have any issues doing this, feel free to respond here.

---

When you enable the browser toolbox, please paste the following code snippet and press enter in the `console` tab. The code runs locally and doesn't send anything to us.

```
(async () => {
  const { PlacesUtils } = ChromeUtils.importESModule(
    "resource://gre/modules/PlacesUtils.sys.mjs",
  );
  const db = await PlacesUtils.promiseLargeCacheDBConnection();

  const threshold = await PlacesUtils.metadata.get(
    "origin_frecency_threshold",
    2.0,
  );
  console.log("Using field: frecency | Autofill threshold:", threshold);

  const hosts = ["news.google.com", "noai.duckduckgo.com"];

  // Origin rows for just the two hosts
  const rows = await db.execute(
    `SELECT prefix, host, frecency
         FROM moz_origins
         WHERE host IN (:h1, :h2, :h3, :h4)
         ORDER BY frecency DESC`,
    { h1: hosts[0], h2: hosts[1] },
  );
  console.table(
    rows.map((r) => ({
      origin: r.getResultByName("prefix") + r.getResultByName("host"),
      frecency: r.getResultByName("frecency"),
    })),
  );

  // Simulated autofill ranking, scoped to the two hosts
  const ranked = await db.execute(
    `SELECT fixup_url(host) AS fixed_host,
                total(frecency) AS total_host_frecency,
                MAX(frecency > 1) AS any_recent_typed,
                group_concat(prefix || host, ', ') AS variants
         FROM moz_origins
         WHERE host IN (:h1, :h2, :h3, :h4)
         GROUP BY fixup_url(host)
         ORDER BY total_host_frecency DESC`,
    { h1: hosts[0], h2: hosts[1] },
  );
  console.table(
    ranked.map((r) => ({
      fixed_host: r.getResultByName("fixed_host"),
      total_host_frecency: r.getResultByName("total_host_frecency"),
      any_recent_typed: r.getResultByName("any_recent_typed"),
      passes_threshold: r.getResultByName("total_host_frecency") >= threshold,
      variants: r.getResultByName("variants"),
    })),
  );

  // noai.duckduckgo.com typed-visit stats (last 90 days)
  const typedDDG = await db.execute(
    `SELECT p.rev_host, COUNT(*) AS typed_visits_90d,
                COUNT(DISTINCT CAST(v.visit_date / (86400 * 1000000) AS INTEGER)) AS typed_days_90d
         FROM moz_historyvisits v
         JOIN moz_places p ON p.id = v.place_id
         WHERE v.visit_type = 2
           AND v.visit_date > (strftime('%s','now') - 90*86400) * 1000000
           AND p.rev_host LIKE :ddg
         GROUP BY p.rev_host`,
    { ddg: "moc.ogkcudkcud.iaon.%" },
  );
  console.log("noai.duckduckgo.com typed visits (last 90 days):");
  console.table(
    typedDDG.map((r) => ({
      rev_host: r.getResultByName("rev_host"),
      typed_visits_90d: r.getResultByName("typed_visits_90d"),
      typed_days_90d: r.getResultByName("typed_days_90d"),
    })),
  );

  // news.google.com typed-visit stats (last 90 days)
  const typedGoogleNews = await db.execute(
    `SELECT p.rev_host, COUNT(*) AS typed_visits_90d,
                COUNT(DISTINCT CAST(v.visit_date / (86400 * 1000000) AS INTEGER)) AS typed_days_90d
         FROM moz_historyvisits v
         JOIN moz_places p ON p.id = v.place_id
         WHERE v.visit_type = 2
           AND v.visit_date > (strftime('%s','now') - 90*86400) * 1000000
           AND p.rev_host LIKE :news
         GROUP BY p.rev_host`,
    { news: "moc.elgoog.swen.%" },
  );
  console.log("news.google.com typed visits (last 90 days):");
  console.table(
    typedGoogleNews.map((r) => ({
      rev_host: r.getResultByName("rev_host"),
      typed_visits_90d: r.getResultByName("typed_visits_90d"),
      typed_days_90d: r.getResultByName("typed_days_90d"),
    })),
  );
})();
```

I've enclose a sample output of what it looks like.
Hi wayfaringbob, what would be helpful for me is for you to show some details that allow me to understand what is happening in your use case as it might reveal a gap in the algorithm. 

Please enable the [Browser Toolbox](https://firefox-source-docs.mozilla.org/devtools-user/browser_toolbox/) so that we can paste a script to get information about your database. If you have any issues doing this, feel free to respond here.

---

When you enable the browser toolbox, please paste the following code snippet and press enter in the `console` tab. The code runs locally and doesn't send anything to us.

```
(async () => {
  const { PlacesUtils } = ChromeUtils.importESModule(
    "resource://gre/modules/PlacesUtils.sys.mjs",
  );
  const db = await PlacesUtils.promiseLargeCacheDBConnection();

  const threshold = await PlacesUtils.metadata.get(
    "origin_frecency_threshold",
    2.0,
  );
  console.log("Using field: frecency | Autofill threshold:", threshold);

  const hosts = ["news.google.com", "noai.duckduckgo.com"];

  // Origin rows for just the two hosts
  const rows = await db.execute(
    `SELECT prefix, host, frecency
         FROM moz_origins
         WHERE host IN (:h1, :h2, :h3, :h4)
         ORDER BY frecency DESC`,
    { h1: hosts[0], h2: hosts[1] },
  );
  console.table(
    rows.map((r) => ({
      origin: r.getResultByName("prefix") + r.getResultByName("host"),
      frecency: r.getResultByName("frecency"),
    })),
  );

  // Simulated autofill ranking, scoped to the two hosts
  const ranked = await db.execute(
    `SELECT fixup_url(host) AS fixed_host,
                total(frecency) AS total_host_frecency,
                MAX(frecency > 1) AS any_recent_typed,
                group_concat(prefix || host, ', ') AS variants
         FROM moz_origins
         WHERE host IN (:h1, :h2, :h3, :h4)
         GROUP BY fixup_url(host)
         ORDER BY total_host_frecency DESC`,
    { h1: hosts[0], h2: hosts[1] },
  );
  console.table(
    ranked.map((r) => ({
      fixed_host: r.getResultByName("fixed_host"),
      total_host_frecency: r.getResultByName("total_host_frecency"),
      any_recent_typed: r.getResultByName("any_recent_typed"),
      passes_threshold: r.getResultByName("total_host_frecency") >= threshold,
      variants: r.getResultByName("variants"),
    })),
  );

  // noai.duckduckgo.com typed-visit stats (last 90 days)
  const typedDDG = await db.execute(
    `SELECT p.rev_host, COUNT(*) AS typed_visits_90d,
                COUNT(DISTINCT CAST(v.visit_date / (86400 * 1000000) AS INTEGER)) AS typed_days_90d
         FROM moz_historyvisits v
         JOIN moz_places p ON p.id = v.place_id
         WHERE v.visit_type = 2
           AND v.visit_date > (strftime('%s','now') - 90*86400) * 1000000
           AND p.rev_host LIKE :ddg
         GROUP BY p.rev_host`,
    { ddg: "moc.ogkcudkcud.iaon.%" },
  );
  console.log("noai.duckduckgo.com typed visits (last 90 days):");
  console.table(
    typedDDG.map((r) => ({
      rev_host: r.getResultByName("rev_host"),
      typed_visits_90d: r.getResultByName("typed_visits_90d"),
      typed_days_90d: r.getResultByName("typed_days_90d"),
    })),
  );

  // news.google.com typed-visit stats (last 90 days)
  const typedGoogleNews = await db.execute(
    `SELECT p.rev_host, COUNT(*) AS typed_visits_90d,
                COUNT(DISTINCT CAST(v.visit_date / (86400 * 1000000) AS INTEGER)) AS typed_days_90d
         FROM moz_historyvisits v
         JOIN moz_places p ON p.id = v.place_id
         WHERE v.visit_type = 2
           AND v.visit_date > (strftime('%s','now') - 90*86400) * 1000000
           AND p.rev_host LIKE :news
         GROUP BY p.rev_host`,
    { news: "moc.elgoog.swen.%" },
  );
  console.log("news.google.com typed visits (last 90 days):");
  console.table(
    typedGoogleNews.map((r) => ({
      rev_host: r.getResultByName("rev_host"),
      typed_visits_90d: r.getResultByName("typed_visits_90d"),
      typed_days_90d: r.getResultByName("typed_days_90d"),
    })),
  );
})();
```

I've enclose a [sample output of what it looks like](https://bugzilla.mozilla.org/attachment.cgi?id=9573087).

Back to Bug 2034513 Comment 3