Bug 1882174: Vendor application-services into mozilla-central r=adw,lina

Differential Revision: https://phabricator.services.mozilla.com/D202894
This commit is contained in:
Daisuke Akatsuka 2024-02-28 02:59:00 +00:00
Родитель a7467e3971
Коммит 46f89effa7
15 изменённых файлов: 269 добавлений и 82 удалений

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

@ -55,9 +55,9 @@ git = "https://github.com/mozilla-spidermonkey/jsparagus"
rev = "61f399c53a641ebd3077c1f39f054f6d396a633c"
replace-with = "vendored-sources"
[source."git+https://github.com/mozilla/application-services?rev=0b241a66c0722290b3a42366378b3f97d8c268d7"]
[source."git+https://github.com/mozilla/application-services?rev=5fc8ee2f0f6950e36d4096983757bd046d55df9f"]
git = "https://github.com/mozilla/application-services"
rev = "0b241a66c0722290b3a42366378b3f97d8c268d7"
rev = "5fc8ee2f0f6950e36d4096983757bd046d55df9f"
replace-with = "vendored-sources"
[source."git+https://github.com/mozilla/audioipc?rev=596bdb7fbb5745ea415726e16bd497e6c850a540"]

24
Cargo.lock сгенерированный
Просмотреть файл

@ -1594,7 +1594,7 @@ dependencies = [
[[package]]
name = "error-support"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=0b241a66c0722290b3a42366378b3f97d8c268d7#0b241a66c0722290b3a42366378b3f97d8c268d7"
source = "git+https://github.com/mozilla/application-services?rev=5fc8ee2f0f6950e36d4096983757bd046d55df9f#5fc8ee2f0f6950e36d4096983757bd046d55df9f"
dependencies = [
"error-support-macros",
"lazy_static",
@ -1606,7 +1606,7 @@ dependencies = [
[[package]]
name = "error-support-macros"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=0b241a66c0722290b3a42366378b3f97d8c268d7#0b241a66c0722290b3a42366378b3f97d8c268d7"
source = "git+https://github.com/mozilla/application-services?rev=5fc8ee2f0f6950e36d4096983757bd046d55df9f#5fc8ee2f0f6950e36d4096983757bd046d55df9f"
dependencies = [
"proc-macro2",
"quote",
@ -2865,7 +2865,7 @@ dependencies = [
[[package]]
name = "interrupt-support"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=0b241a66c0722290b3a42366378b3f97d8c268d7#0b241a66c0722290b3a42366378b3f97d8c268d7"
source = "git+https://github.com/mozilla/application-services?rev=5fc8ee2f0f6950e36d4096983757bd046d55df9f#5fc8ee2f0f6950e36d4096983757bd046d55df9f"
dependencies = [
"lazy_static",
"parking_lot",
@ -4051,7 +4051,7 @@ dependencies = [
[[package]]
name = "nss_build_common"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=0b241a66c0722290b3a42366378b3f97d8c268d7#0b241a66c0722290b3a42366378b3f97d8c268d7"
source = "git+https://github.com/mozilla/application-services?rev=5fc8ee2f0f6950e36d4096983757bd046d55df9f#5fc8ee2f0f6950e36d4096983757bd046d55df9f"
[[package]]
name = "nsstring"
@ -4733,7 +4733,7 @@ checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da"
[[package]]
name = "remote_settings"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=0b241a66c0722290b3a42366378b3f97d8c268d7#0b241a66c0722290b3a42366378b3f97d8c268d7"
source = "git+https://github.com/mozilla/application-services?rev=5fc8ee2f0f6950e36d4096983757bd046d55df9f#5fc8ee2f0f6950e36d4096983757bd046d55df9f"
dependencies = [
"parking_lot",
"serde",
@ -5256,7 +5256,7 @@ dependencies = [
[[package]]
name = "sql-support"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=0b241a66c0722290b3a42366378b3f97d8c268d7#0b241a66c0722290b3a42366378b3f97d8c268d7"
source = "git+https://github.com/mozilla/application-services?rev=5fc8ee2f0f6950e36d4096983757bd046d55df9f#5fc8ee2f0f6950e36d4096983757bd046d55df9f"
dependencies = [
"ffi-support",
"interrupt-support",
@ -5437,7 +5437,7 @@ checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc"
[[package]]
name = "suggest"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=0b241a66c0722290b3a42366378b3f97d8c268d7#0b241a66c0722290b3a42366378b3f97d8c268d7"
source = "git+https://github.com/mozilla/application-services?rev=5fc8ee2f0f6950e36d4096983757bd046d55df9f#5fc8ee2f0f6950e36d4096983757bd046d55df9f"
dependencies = [
"anyhow",
"chrono",
@ -5486,7 +5486,7 @@ dependencies = [
[[package]]
name = "sync-guid"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=0b241a66c0722290b3a42366378b3f97d8c268d7#0b241a66c0722290b3a42366378b3f97d8c268d7"
source = "git+https://github.com/mozilla/application-services?rev=5fc8ee2f0f6950e36d4096983757bd046d55df9f#5fc8ee2f0f6950e36d4096983757bd046d55df9f"
dependencies = [
"base64 0.21.3",
"rand",
@ -5497,7 +5497,7 @@ dependencies = [
[[package]]
name = "sync15"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=0b241a66c0722290b3a42366378b3f97d8c268d7#0b241a66c0722290b3a42366378b3f97d8c268d7"
source = "git+https://github.com/mozilla/application-services?rev=5fc8ee2f0f6950e36d4096983757bd046d55df9f#5fc8ee2f0f6950e36d4096983757bd046d55df9f"
dependencies = [
"anyhow",
"error-support",
@ -5529,7 +5529,7 @@ dependencies = [
[[package]]
name = "tabs"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=0b241a66c0722290b3a42366378b3f97d8c268d7#0b241a66c0722290b3a42366378b3f97d8c268d7"
source = "git+https://github.com/mozilla/application-services?rev=5fc8ee2f0f6950e36d4096983757bd046d55df9f#5fc8ee2f0f6950e36d4096983757bd046d55df9f"
dependencies = [
"anyhow",
"error-support",
@ -6181,7 +6181,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]]
name = "viaduct"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=0b241a66c0722290b3a42366378b3f97d8c268d7#0b241a66c0722290b3a42366378b3f97d8c268d7"
source = "git+https://github.com/mozilla/application-services?rev=5fc8ee2f0f6950e36d4096983757bd046d55df9f#5fc8ee2f0f6950e36d4096983757bd046d55df9f"
dependencies = [
"ffi-support",
"log",
@ -6327,7 +6327,7 @@ dependencies = [
[[package]]
name = "webext-storage"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=0b241a66c0722290b3a42366378b3f97d8c268d7#0b241a66c0722290b3a42366378b3f97d8c268d7"
source = "git+https://github.com/mozilla/application-services?rev=5fc8ee2f0f6950e36d4096983757bd046d55df9f#5fc8ee2f0f6950e36d4096983757bd046d55df9f"
dependencies = [
"anyhow",
"error-support",

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

@ -207,13 +207,13 @@ warp = { git = "https://github.com/seanmonstar/warp", rev = "9d081461ae1167eb321
malloc_size_of_derive = { path = "xpcom/rust/malloc_size_of_derive" }
# application-services overrides to make updating them all simpler.
interrupt-support = { git = "https://github.com/mozilla/application-services", rev = "0b241a66c0722290b3a42366378b3f97d8c268d7" }
sql-support = { git = "https://github.com/mozilla/application-services", rev = "0b241a66c0722290b3a42366378b3f97d8c268d7" }
suggest = { git = "https://github.com/mozilla/application-services", rev = "0b241a66c0722290b3a42366378b3f97d8c268d7" }
sync15 = { git = "https://github.com/mozilla/application-services", rev = "0b241a66c0722290b3a42366378b3f97d8c268d7" }
tabs = { git = "https://github.com/mozilla/application-services", rev = "0b241a66c0722290b3a42366378b3f97d8c268d7" }
viaduct = { git = "https://github.com/mozilla/application-services", rev = "0b241a66c0722290b3a42366378b3f97d8c268d7" }
webext-storage = { git = "https://github.com/mozilla/application-services", rev = "0b241a66c0722290b3a42366378b3f97d8c268d7" }
interrupt-support = { git = "https://github.com/mozilla/application-services", rev = "5fc8ee2f0f6950e36d4096983757bd046d55df9f" }
sql-support = { git = "https://github.com/mozilla/application-services", rev = "5fc8ee2f0f6950e36d4096983757bd046d55df9f" }
suggest = { git = "https://github.com/mozilla/application-services", rev = "5fc8ee2f0f6950e36d4096983757bd046d55df9f" }
sync15 = { git = "https://github.com/mozilla/application-services", rev = "5fc8ee2f0f6950e36d4096983757bd046d55df9f" }
tabs = { git = "https://github.com/mozilla/application-services", rev = "5fc8ee2f0f6950e36d4096983757bd046d55df9f" }
viaduct = { git = "https://github.com/mozilla/application-services", rev = "5fc8ee2f0f6950e36d4096983757bd046d55df9f" }
webext-storage = { git = "https://github.com/mozilla/application-services", rev = "5fc8ee2f0f6950e36d4096983757bd046d55df9f" }
# Patch mio 0.8.8 to use windows-sys 0.52 (backport https://github.com/tokio-rs/mio/commit/eea9e3e0c469480e5c59c01e6c3c7e5fd88f0848)
mio_0_8 = { package = "mio", git = "https://github.com/glandium/mio", rev = "9a2ef335c366044ffe73b1c4acabe50a1daefe05" }

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

@ -15,6 +15,7 @@ const REMOTE_SETTINGS_RECORDS = [
locationSigns: [{ keyword: "in", needLocation: true }],
yelpModifiers: [],
icon: "1234",
score: 0.5,
},
},
];

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

@ -18,6 +18,7 @@ const REMOTE_SETTINGS_RECORDS = [
locationSigns: [{ keyword: "in", needLocation: true }],
yelpModifiers: [],
icon: "1234",
score: 0.5,
},
},
];

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

@ -1 +1 @@
{"files":{"Cargo.toml":"6597b6d5217376ab747534364a58958ddbb23ffda52045e68b610cd8f2dcdfd1","src/lib.rs":"0abb87e42c9fb1c8e199721a258ef6d6eb05df0efd1e4e0696fc60cc3440041f"},"package":null}
{"files":{"Cargo.toml":"6597b6d5217376ab747534364a58958ddbb23ffda52045e68b610cd8f2dcdfd1","src/lib.rs":"9f7379d76c3c663fba7aceb0cc273ab459e1dd9a25664354402c3895bbd25240"},"package":null}

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

@ -92,13 +92,13 @@ fn link_nss_libs(kind: LinkingKind) {
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
if target_arch == "x86_64" && target_os == "android" {
let android_home = env::var("ANDROID_HOME").expect("ANDROID_HOME not set");
const ANDROID_NDK_VERSION: &str = "25.2.9519653";
const ANDROID_NDK_VERSION: &str = "26.2.11394342";
// One of these will exist, depending on the host platform.
const DARWIN_X86_64_LIB_DIR: &str =
"/toolchains/llvm/prebuilt/darwin-x86_64/lib64/clang/14.0.7/lib/linux/";
"/toolchains/llvm/prebuilt/darwin-x86_64/lib/clang/17/lib/linux/";
println!("cargo:rustc-link-search={android_home}/ndk/{ANDROID_NDK_VERSION}/{DARWIN_X86_64_LIB_DIR}");
const LINUX_X86_64_LIB_DIR: &str =
"/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/14.0.7/lib/linux/";
"/toolchains/llvm/prebuilt/linux-x86_64/lib/clang/17/lib/linux/";
println!("cargo:rustc-link-search={android_home}/ndk/{ANDROID_NDK_VERSION}/{LINUX_X86_64_LIB_DIR}");
println!("cargo:rustc-link-lib=static=clang_rt.builtins-x86_64-android");
}

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

@ -1 +1 @@
{"files":{"Cargo.toml":"4aa81cff67e67b08ba3348c1acddaa5aee887df3c35006754c9cda4273a94458","README.md":"8d7457893194e255b87e5a2667ee25c87bd470f5338d7078506f866a67a3fdbd","build.rs":"78780c5cccfe22c3ff4198624b9e188559c437c3e6fa1c8bb66548eee6aa66bf","src/config.rs":"03630b2219b6674e332a1f96f44db74def17f985c850a800299b815fa72241c2","src/db.rs":"d373ad097edac2bbcc6e1b14f51c21b6e2cab2289d27667332798c9cde4dcbef","src/error.rs":"f563210a6c050d98ec85e0f6d9401e7373bfb816e865e8edabbabb23d848ba13","src/keyword.rs":"988d0ab021c0df19cfd3c519df7d37f606bf984cd14d0efca4e5a7aff88344dd","src/lib.rs":"65a035dbfb17e2d2d9f237ad52dc03982ae28c70e3dcf3d96cc9f2d7af79efe3","src/pocket.rs":"c4dda43390d1c39dc795933596b3c1e4e282932cac6c69da53c6e05d39e9ef29","src/provider.rs":"4fe662587efc5a80d000c217ce124506c6800293c50ff460ef95e9e659c764b9","src/rs.rs":"5dc41f6fac152b9f87d77a6b97b30377403d089649c35f6550460494d79246d0","src/schema.rs":"4c7264cd70050fbc1f711c80727ca65f7103d0e06d9247eacc5cc42b965bcd6f","src/store.rs":"77e1b8580fbd5e725a20d8da721e420306a762331046cb46faa4cee239ebe946","src/suggest.udl":"7dcc48cadcac44f67830d320b1e964e59d389b935107f18a066e5b30275073e7","src/suggestion.rs":"5994710ddefbcb4589e25b7b89854344b58bfb6754e13d0aa0549a8c188a0899","src/yelp.rs":"8f90146f5b32ea04b7506cae217c5025d532337ac9acd977866f110979559101","uniffi.toml":"f26317442ddb5b3281245bef6e60ffcb78bb95d29fe4a351a56dbb88d4ec8aab"},"package":null}
{"files":{"Cargo.toml":"4aa81cff67e67b08ba3348c1acddaa5aee887df3c35006754c9cda4273a94458","README.md":"8d7457893194e255b87e5a2667ee25c87bd470f5338d7078506f866a67a3fdbd","build.rs":"78780c5cccfe22c3ff4198624b9e188559c437c3e6fa1c8bb66548eee6aa66bf","src/config.rs":"03630b2219b6674e332a1f96f44db74def17f985c850a800299b815fa72241c2","src/db.rs":"d373ad097edac2bbcc6e1b14f51c21b6e2cab2289d27667332798c9cde4dcbef","src/error.rs":"f563210a6c050d98ec85e0f6d9401e7373bfb816e865e8edabbabb23d848ba13","src/keyword.rs":"988d0ab021c0df19cfd3c519df7d37f606bf984cd14d0efca4e5a7aff88344dd","src/lib.rs":"65a035dbfb17e2d2d9f237ad52dc03982ae28c70e3dcf3d96cc9f2d7af79efe3","src/pocket.rs":"c4dda43390d1c39dc795933596b3c1e4e282932cac6c69da53c6e05d39e9ef29","src/provider.rs":"4fe662587efc5a80d000c217ce124506c6800293c50ff460ef95e9e659c764b9","src/rs.rs":"0910368f9e7c4703b00d0de86902d647d70c1f75a256fbeb2126c91f0499a083","src/schema.rs":"8fad4cc624f48946676adbc3de7d061f05fe82531523008f417d6130a2132e34","src/store.rs":"a869971d5593bec2dd40822ba63d0e5a5def96a870ff5a7c33afbcbf5869946b","src/suggest.udl":"d941662596d48793d1570e5b8432b7fd7b4fb1b4550fb38d4e14224fcf4195bc","src/suggestion.rs":"7ee407949f40d88e5d3d4c0da400b987e85ace9f34c648f010cd7f5f2aba0506","src/yelp.rs":"37e77900c12c68cca292a84c6dd6c67d16628c68f4612d8d9bedb1bddf985229","uniffi.toml":"f26317442ddb5b3281245bef6e60ffcb78bb95d29fe4a351a56dbb88d4ec8aab"},"package":null}

1
third_party/rust/suggest/src/rs.rs поставляемый
Просмотреть файл

@ -298,6 +298,7 @@ pub(crate) struct DownloadedYelpSuggestion {
pub yelp_modifiers: Vec<String>,
#[serde(rename = "icon")]
pub icon_id: String,
pub score: f64,
}
/// An MDN suggestion to ingest from an attachment

5
third_party/rust/suggest/src/schema.rs поставляемый
Просмотреть файл

@ -13,7 +13,7 @@ use sql_support::open_database::{self, ConnectionInitializer};
/// 1. Bump this version.
/// 2. Add a migration from the old version to the new version in
/// [`SuggestConnectionInitializer::upgrade_from`].
pub const VERSION: u32 = 13;
pub const VERSION: u32 = 14;
/// The current Suggest database schema.
pub const SQL: &str = "
@ -102,6 +102,7 @@ pub const SQL: &str = "
CREATE TABLE yelp_custom_details(
icon_id TEXT PRIMARY KEY,
score REAL NOT NULL,
record_id TEXT NOT NULL
) WITHOUT ROWID;
@ -140,7 +141,7 @@ impl ConnectionInitializer for SuggestConnectionInitializer {
fn upgrade_from(&self, _db: &Transaction<'_>, version: u32) -> open_database::Result<()> {
match version {
1..=12 => {
1..=13 => {
// Treat databases with these older schema versions as corrupt,
// so that they'll be replaced by a fresh, empty database with
// the current schema.

215
third_party/rust/suggest/src/store.rs поставляемый
Просмотреть файл

@ -2001,7 +2001,8 @@ mod tests {
{ "keyword": "near me", "needLocation": false },
],
"yelpModifiers": ["yelp", "yelp keyword"],
"icon": "yelp-favicon"
"icon": "yelp-favicon",
"score": 0.5
}),
)?
.with_data(
@ -2600,7 +2601,6 @@ mod tests {
Yelp {
url: "https://www.yelp.com/search?find_desc=best+spicy+ramen+delivery&find_loc=tokyo",
title: "best spicy ramen delivery in tokyo",
subject_exact_match: true,
icon: Some(
[
121,
@ -2614,6 +2614,10 @@ mod tests {
110,
],
),
score: 0.5,
has_location_sign: true,
subject_exact_match: true,
location_param: "find_loc",
},
]
"#]],
@ -2630,7 +2634,6 @@ mod tests {
Yelp {
url: "https://www.yelp.com/search?find_desc=BeSt+SpIcY+rAmEn+DeLiVeRy&find_loc=ToKyO",
title: "BeSt SpIcY rAmEn DeLiVeRy In ToKyO",
subject_exact_match: true,
icon: Some(
[
121,
@ -2644,6 +2647,10 @@ mod tests {
110,
],
),
score: 0.5,
has_location_sign: true,
subject_exact_match: true,
location_param: "find_loc",
},
]
"#]],
@ -2660,7 +2667,6 @@ mod tests {
Yelp {
url: "https://www.yelp.com/search?find_desc=best+ramen+delivery&find_loc=tokyo",
title: "best ramen delivery in tokyo",
subject_exact_match: true,
icon: Some(
[
121,
@ -2674,6 +2680,10 @@ mod tests {
110,
],
),
score: 0.5,
has_location_sign: true,
subject_exact_match: true,
location_param: "find_loc",
},
]
"#]],
@ -2712,7 +2722,6 @@ mod tests {
Yelp {
url: "https://www.yelp.com/search?find_desc=super+best+ramen+delivery&find_loc=tokyo",
title: "super best ramen delivery in tokyo",
subject_exact_match: true,
icon: Some(
[
121,
@ -2726,6 +2735,10 @@ mod tests {
110,
],
),
score: 0.5,
has_location_sign: true,
subject_exact_match: true,
location_param: "find_loc",
},
]
"#]],
@ -2753,7 +2766,6 @@ mod tests {
Yelp {
url: "https://www.yelp.com/search?find_desc=ramen+delivery&find_loc=tokyo",
title: "ramen delivery in tokyo",
subject_exact_match: true,
icon: Some(
[
121,
@ -2767,6 +2779,10 @@ mod tests {
110,
],
),
score: 0.5,
has_location_sign: true,
subject_exact_match: true,
location_param: "find_loc",
},
]
"#]],
@ -2783,7 +2799,6 @@ mod tests {
Yelp {
url: "https://www.yelp.com/search?find_desc=ramen+super+delivery&find_loc=tokyo",
title: "ramen super delivery in tokyo",
subject_exact_match: true,
icon: Some(
[
121,
@ -2797,6 +2812,10 @@ mod tests {
110,
],
),
score: 0.5,
has_location_sign: true,
subject_exact_match: true,
location_param: "find_loc",
},
]
"#]],
@ -2824,7 +2843,6 @@ mod tests {
Yelp {
url: "https://www.yelp.com/search?find_desc=ramen&find_loc=tokyo",
title: "ramen in tokyo",
subject_exact_match: true,
icon: Some(
[
121,
@ -2838,6 +2856,10 @@ mod tests {
110,
],
),
score: 0.5,
has_location_sign: true,
subject_exact_match: true,
location_param: "find_loc",
},
]
"#]],
@ -2854,7 +2876,6 @@ mod tests {
Yelp {
url: "https://www.yelp.com/search?find_desc=ramen&find_loc=tokyo",
title: "ramen near tokyo",
subject_exact_match: true,
icon: Some(
[
121,
@ -2868,6 +2889,10 @@ mod tests {
110,
],
),
score: 0.5,
has_location_sign: true,
subject_exact_match: true,
location_param: "find_loc",
},
]
"#]],
@ -2895,7 +2920,6 @@ mod tests {
Yelp {
url: "https://www.yelp.com/search?find_desc=ramen&find_loc=San+Francisco",
title: "ramen in San Francisco",
subject_exact_match: true,
icon: Some(
[
121,
@ -2909,6 +2933,10 @@ mod tests {
110,
],
),
score: 0.5,
has_location_sign: true,
subject_exact_match: true,
location_param: "find_loc",
},
]
"#]],
@ -2925,7 +2953,6 @@ mod tests {
Yelp {
url: "https://www.yelp.com/search?find_desc=ramen",
title: "ramen in",
subject_exact_match: true,
icon: Some(
[
121,
@ -2939,6 +2966,10 @@ mod tests {
110,
],
),
score: 0.5,
has_location_sign: true,
subject_exact_match: true,
location_param: "find_loc",
},
]
"#]],
@ -2955,7 +2986,6 @@ mod tests {
Yelp {
url: "https://www.yelp.com/search?find_desc=ramen+near+by",
title: "ramen near by",
subject_exact_match: true,
icon: Some(
[
121,
@ -2969,6 +2999,10 @@ mod tests {
110,
],
),
score: 0.5,
has_location_sign: false,
subject_exact_match: true,
location_param: "find_loc",
},
]
"#]],
@ -2985,7 +3019,6 @@ mod tests {
Yelp {
url: "https://www.yelp.com/search?find_desc=ramen+near+me",
title: "ramen near me",
subject_exact_match: true,
icon: Some(
[
121,
@ -2999,6 +3032,10 @@ mod tests {
110,
],
),
score: 0.5,
has_location_sign: false,
subject_exact_match: true,
location_param: "find_loc",
},
]
"#]],
@ -3026,7 +3063,6 @@ mod tests {
Yelp {
url: "https://www.yelp.com/search?find_desc=ramen",
title: "ramen",
subject_exact_match: true,
icon: Some(
[
121,
@ -3040,6 +3076,10 @@ mod tests {
110,
],
),
score: 0.5,
has_location_sign: false,
subject_exact_match: true,
location_param: "find_loc",
},
]
"#]],
@ -3056,7 +3096,6 @@ mod tests {
Yelp {
url: "https://www.yelp.com/search?find_desc=012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789",
title: "012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789",
subject_exact_match: true,
icon: Some(
[
121,
@ -3070,6 +3109,10 @@ mod tests {
110,
],
),
score: 0.5,
has_location_sign: false,
subject_exact_match: true,
location_param: "find_loc",
},
]
"#]],
@ -3130,7 +3173,6 @@ mod tests {
Yelp {
url: "https://www.yelp.com/search?find_desc=ramen",
title: "ramen",
subject_exact_match: true,
icon: Some(
[
121,
@ -3144,6 +3186,10 @@ mod tests {
110,
],
),
score: 0.5,
has_location_sign: false,
subject_exact_match: true,
location_param: "find_loc",
},
]
"#]],
@ -3160,7 +3206,6 @@ mod tests {
Yelp {
url: "https://www.yelp.com/search?find_desc=ramen",
title: "ramen",
subject_exact_match: true,
icon: Some(
[
121,
@ -3174,6 +3219,10 @@ mod tests {
110,
],
),
score: 0.5,
has_location_sign: false,
subject_exact_match: true,
location_param: "find_loc",
},
]
"#]],
@ -3190,7 +3239,6 @@ mod tests {
Yelp {
url: "https://www.yelp.com/search?find_desc=ramen&find_loc=tokyo",
title: "ramen in tokyo",
subject_exact_match: true,
icon: Some(
[
121,
@ -3204,6 +3252,10 @@ mod tests {
110,
],
),
score: 0.5,
has_location_sign: true,
subject_exact_match: true,
location_param: "find_loc",
},
]
"#]],
@ -3220,7 +3272,6 @@ mod tests {
Yelp {
url: "https://www.yelp.com/search?find_desc=ramen&find_loc=tokyo",
title: "ramen in tokyo",
subject_exact_match: true,
icon: Some(
[
121,
@ -3234,6 +3285,10 @@ mod tests {
110,
],
),
score: 0.5,
has_location_sign: true,
subject_exact_match: true,
location_param: "find_loc",
},
]
"#]],
@ -3250,7 +3305,6 @@ mod tests {
Yelp {
url: "https://www.yelp.com/search?find_desc=ramen",
title: "ramen",
subject_exact_match: true,
icon: Some(
[
121,
@ -3264,6 +3318,10 @@ mod tests {
110,
],
),
score: 0.5,
has_location_sign: false,
subject_exact_match: true,
location_param: "find_loc",
},
]
"#]],
@ -3291,7 +3349,6 @@ mod tests {
Yelp {
url: "https://www.yelp.com/search?find_desc=Spicy+Ramen",
title: "Spicy Ramen",
subject_exact_match: false,
icon: Some(
[
121,
@ -3305,6 +3362,10 @@ mod tests {
110,
],
),
score: 0.5,
has_location_sign: false,
subject_exact_match: false,
location_param: "find_loc",
},
]
"#]],
@ -3321,7 +3382,6 @@ mod tests {
Yelp {
url: "https://www.yelp.com/search?find_desc=BeSt+Ramen",
title: "BeSt Ramen",
subject_exact_match: true,
icon: Some(
[
121,
@ -3335,6 +3395,10 @@ mod tests {
110,
],
),
score: 0.5,
has_location_sign: false,
subject_exact_match: true,
location_param: "find_loc",
},
]
"#]],
@ -3351,7 +3415,6 @@ mod tests {
Yelp {
url: "https://www.yelp.com/search?find_desc=BeSt+Spicy+Ramen",
title: "BeSt Spicy Ramen",
subject_exact_match: false,
icon: Some(
[
121,
@ -3365,6 +3428,10 @@ mod tests {
110,
],
),
score: 0.5,
has_location_sign: false,
subject_exact_match: false,
location_param: "find_loc",
},
]
"#]],
@ -3403,7 +3470,6 @@ mod tests {
Yelp {
url: "https://www.yelp.com/search?find_desc=rats",
title: "rats",
subject_exact_match: false,
icon: Some(
[
121,
@ -3417,6 +3483,10 @@ mod tests {
110,
],
),
score: 0.5,
has_location_sign: false,
subject_exact_match: false,
location_param: "find_loc",
},
]
"#]],
@ -3433,7 +3503,6 @@ mod tests {
Yelp {
url: "https://www.yelp.com/search?find_desc=ramen",
title: "ramen",
subject_exact_match: false,
icon: Some(
[
121,
@ -3447,6 +3516,10 @@ mod tests {
110,
],
),
score: 0.5,
has_location_sign: false,
subject_exact_match: false,
location_param: "find_loc",
},
]
"#]],
@ -3463,7 +3536,6 @@ mod tests {
Yelp {
url: "https://www.yelp.com/search?find_desc=raccoon",
title: "raccoon",
subject_exact_match: false,
icon: Some(
[
121,
@ -3477,6 +3549,10 @@ mod tests {
110,
],
),
score: 0.5,
has_location_sign: false,
subject_exact_match: false,
location_param: "find_loc",
},
]
"#]],
@ -3504,7 +3580,6 @@ mod tests {
Yelp {
url: "https://www.yelp.com/search?find_desc=best+rats",
title: "best rats",
subject_exact_match: false,
icon: Some(
[
121,
@ -3518,6 +3593,10 @@ mod tests {
110,
],
),
score: 0.5,
has_location_sign: false,
subject_exact_match: false,
location_param: "find_loc",
},
]
"#]],
@ -4327,10 +4406,10 @@ mod tests {
UnparsableRecords(
{
"clippy-2": UnparsableRecord {
schema_version: 13,
schema_version: 14,
},
"fancy-new-suggestions-1": UnparsableRecord {
schema_version: 13,
schema_version: 14,
},
},
),
@ -4396,10 +4475,10 @@ mod tests {
UnparsableRecords(
{
"clippy-2": UnparsableRecord {
schema_version: 13,
schema_version: 14,
},
"fancy-new-suggestions-1": UnparsableRecord {
schema_version: 13,
schema_version: 14,
},
},
),
@ -4503,10 +4582,10 @@ mod tests {
UnparsableRecords(
{
"clippy-2": UnparsableRecord {
schema_version: 13,
schema_version: 14,
},
"fancy-new-suggestions-1": UnparsableRecord {
schema_version: 13,
schema_version: 14,
},
},
),
@ -4592,7 +4671,7 @@ mod tests {
UnparsableRecords(
{
"invalid-attachment": UnparsableRecord {
schema_version: 13,
schema_version: 14,
},
},
),
@ -4772,6 +4851,74 @@ mod tests {
Ok(())
}
#[test]
fn query_no_yelp_icon_data() -> anyhow::Result<()> {
before_each();
let snapshot = Snapshot::with_records(json!([{
"id": "data-1",
"type": "yelp-suggestions",
"last_modified": 15,
"attachment": {
"filename": "data-1.json",
"mimetype": "application/json",
"location": "data-1.json",
"hash": "",
"size": 0,
},
}]))?
.with_data(
"data-1.json",
json!([
{
"subjects": ["ramen"],
"preModifiers": [],
"postModifiers": [],
"locationSigns": [],
"yelpModifiers": [],
"icon": "yelp-favicon",
"score": 0.5
},
]),
)?;
let store = unique_test_store(SnapshotSettingsClient::with_snapshot(snapshot));
store.ingest(SuggestIngestionConstraints::default())?;
let table = [(
"keyword = ramen; Yelp only",
SuggestionQuery {
keyword: "ramen".into(),
providers: vec![SuggestionProvider::Yelp],
limit: None,
},
expect![[r#"
[
Yelp {
url: "https://www.yelp.com/search?find_desc=ramen",
title: "ramen",
icon: None,
score: 0.5,
has_location_sign: false,
subject_exact_match: true,
location_param: "find_loc",
},
]
"#]],
)];
for (what, query, expect) in table {
expect.assert_debug_eq(
&store
.query(query)
.with_context(|| format!("Couldn't query store for {}", what))?,
);
}
Ok(())
}
#[test]
fn weather() -> anyhow::Result<()> {
before_each();

5
third_party/rust/suggest/src/suggest.udl поставляемый
Просмотреть файл

@ -74,8 +74,11 @@ interface Suggestion {
Yelp(
string url,
string title,
sequence<u8>? icon,
f64 score,
boolean has_location_sign,
boolean subject_exact_match,
sequence<u8>? icon
string location_param
);
Mdn(
string title,

5
third_party/rust/suggest/src/suggestion.rs поставляемый
Просмотреть файл

@ -63,8 +63,11 @@ pub enum Suggestion {
Yelp {
url: String,
title: String,
subject_exact_match: bool,
icon: Option<Vec<u8>>,
score: f64,
has_location_sign: bool,
subject_exact_match: bool,
location_param: String,
},
Mdn {
title: String,

41
third_party/rust/suggest/src/yelp.rs поставляемый
Просмотреть файл

@ -118,10 +118,11 @@ impl<'a> SuggestDao<'a> {
self.scope.err_if_interrupted()?;
self.conn.execute_cached(
"INSERT INTO yelp_custom_details(record_id, icon_id) VALUES(:record_id, :icon_id)",
"INSERT INTO yelp_custom_details(record_id, icon_id, score) VALUES(:record_id, :icon_id, :score)",
named_params! {
":record_id": record_id.as_str(),
":icon_id": suggestion.icon_id
":icon_id": suggestion.icon_id,
":score": suggestion.score,
},
)?;
@ -143,7 +144,7 @@ impl<'a> SuggestDao<'a> {
let Some((subject, subject_exact_match)) = self.find_subject(query_string)? else {
return Ok(vec![]);
};
let icon = self.fetch_icon()?;
let (icon, score) = self.fetch_custom_details()?;
let builder = SuggestionBuilder {
subject: &subject,
subject_exact_match,
@ -153,6 +154,7 @@ impl<'a> SuggestDao<'a> {
location: None,
need_location: false,
icon,
score,
};
return Ok(vec![builder.into()]);
}
@ -183,7 +185,7 @@ impl<'a> SuggestDao<'a> {
return Ok(vec![]);
};
let icon = self.fetch_icon()?;
let (icon, score) = self.fetch_custom_details()?;
let builder = SuggestionBuilder {
subject: &subject,
subject_exact_match,
@ -193,33 +195,42 @@ impl<'a> SuggestDao<'a> {
location,
need_location,
icon,
score,
};
Ok(vec![builder.into()])
}
/// Fetch the icon for Yelp suggestions.
/// Fetch the custom details for Yelp suggestions.
/// It returns the location tuple as follows:
/// (
/// Option<Vec<u8>>: Icon data. If not found, returns None.
/// f64: Reflects score field in the yelp_custom_details table.
/// )
///
/// Note that there should be only one record in `yelp_custom_details`
/// as all the Yelp assets are stored in the attachment of a single record
/// on Remote Settings. The following query will perform a table scan against
/// `yelp_custom_details` followed by an index search against `icons`, which
/// should be fine since there is only one record in the first table.
fn fetch_icon(&self) -> Result<Option<Vec<u8>>> {
Ok(self.conn.try_query_one(
/// `yelp_custom_details` followed by an index search against `icons`,
/// which should be fine since there is only one record in the first table.
fn fetch_custom_details(&self) -> Result<(Option<Vec<u8>>, f64)> {
let result = self.conn.query_row_and_then_cachable(
r#"
SELECT
i.data
i.data, y.score
FROM
yelp_custom_details y
JOIN
LEFT JOIN
icons i
ON y.icon_id = i.id
LIMIT
1
"#,
(),
|row| -> Result<_> { Ok((row.get::<_, Option<Vec<u8>>>(0)?, row.get::<_, f64>(1)?)) },
true,
)?)
)?;
Ok(result)
}
/// Find the location information from the given query string.
@ -428,6 +439,7 @@ struct SuggestionBuilder<'a> {
location: Option<String>,
need_location: bool,
icon: Option<Vec<u8>>,
score: f64,
}
impl<'a> From<SuggestionBuilder<'a>> for Suggestion {
@ -475,8 +487,11 @@ impl<'a> From<SuggestionBuilder<'a>> for Suggestion {
Suggestion::Yelp {
url,
title,
subject_exact_match: builder.subject_exact_match,
icon: builder.icon,
score: builder.score,
has_location_sign: location_modifier.is_none() && builder.location_sign.is_some(),
subject_exact_match: builder.subject_exact_match,
location_param: "find_loc".to_string(),
}
}
}

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

@ -1252,14 +1252,20 @@ Suggestion.Yelp = class extends Suggestion{
constructor(
url,
title,
icon,
score,
hasLocationSign,
subjectExactMatch,
icon
locationParam
) {
super();
this.url = url;
this.title = title;
this.subjectExactMatch = subjectExactMatch;
this.icon = icon;
this.score = score;
this.hasLocationSign = hasLocationSign;
this.subjectExactMatch = subjectExactMatch;
this.locationParam = locationParam;
}
}
Suggestion.Mdn = class extends Suggestion{
@ -1333,8 +1339,11 @@ export class FfiConverterTypeSuggestion extends FfiConverterArrayBuffer {
return new Suggestion.Yelp(
FfiConverterString.read(dataStream),
FfiConverterString.read(dataStream),
FfiConverterOptionalSequenceu8.read(dataStream),
FfiConverterF64.read(dataStream),
FfiConverterBool.read(dataStream),
FfiConverterOptionalSequenceu8.read(dataStream)
FfiConverterBool.read(dataStream),
FfiConverterString.read(dataStream)
);
case 6:
return new Suggestion.Mdn(
@ -1401,8 +1410,11 @@ export class FfiConverterTypeSuggestion extends FfiConverterArrayBuffer {
dataStream.writeInt32(5);
FfiConverterString.write(dataStream, value.url);
FfiConverterString.write(dataStream, value.title);
FfiConverterBool.write(dataStream, value.subjectExactMatch);
FfiConverterOptionalSequenceu8.write(dataStream, value.icon);
FfiConverterF64.write(dataStream, value.score);
FfiConverterBool.write(dataStream, value.hasLocationSign);
FfiConverterBool.write(dataStream, value.subjectExactMatch);
FfiConverterString.write(dataStream, value.locationParam);
return;
}
if (value instanceof Suggestion.Mdn) {
@ -1467,8 +1479,11 @@ export class FfiConverterTypeSuggestion extends FfiConverterArrayBuffer {
if (value instanceof Suggestion.Yelp) {
totalSize += FfiConverterString.computeSize(value.url);
totalSize += FfiConverterString.computeSize(value.title);
totalSize += FfiConverterBool.computeSize(value.subjectExactMatch);
totalSize += FfiConverterOptionalSequenceu8.computeSize(value.icon);
totalSize += FfiConverterF64.computeSize(value.score);
totalSize += FfiConverterBool.computeSize(value.hasLocationSign);
totalSize += FfiConverterBool.computeSize(value.subjectExactMatch);
totalSize += FfiConverterString.computeSize(value.locationParam);
return totalSize;
}
if (value instanceof Suggestion.Mdn) {