Created
March 8, 2024 01:16
-
-
Save bendk/9b28f66d6451ffcc8922c470cd630326 to your computer and use it in GitHub Desktop.
This file contains 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
diff --git a/components/suggest/src/db.rs b/components/suggest/src/db.rs | |
index b92942d8e..a237f6893 100644 | |
--- a/components/suggest/src/db.rs | |
+++ b/components/suggest/src/db.rs | |
@@ -400,7 +400,7 @@ impl<'a> SuggestDao<'a> { | |
&self, | |
query: &SuggestionQuery, | |
provider: &SuggestionProvider, | |
- mapper: impl FnMut(&rusqlite::Row) -> Result<T>, | |
+ mut mapper: impl FnMut(&rusqlite::Row, &str, &str) -> Result<T>, | |
) -> Result<Vec<T>> { | |
let keyword_lowercased = &query.keyword.to_lowercase(); | |
let (keyword_prefix, keyword_suffix) = split_keyword(keyword_lowercased); | |
@@ -438,19 +438,17 @@ impl<'a> SuggestDao<'a> { | |
(":provider", provider as &dyn ToSql), | |
(":suggestions_limit", &suggestions_limit as &dyn ToSql), | |
], | |
- mapper, | |
+ |row| mapper(row, keyword_prefix, keyword_suffix), | |
) | |
} | |
/// Fetches Suggestions of type Amo provider that match the given query | |
pub fn fetch_amo_suggestions(&self, query: &SuggestionQuery) -> Result<Vec<Suggestion>> { | |
- let keyword_lowercased = &query.keyword.to_lowercase(); | |
- let (_, keyword_suffix) = split_keyword(keyword_lowercased); | |
let suggestions = self | |
.map_prefix_keywords( | |
query, | |
&SuggestionProvider::Amo, | |
- |row| -> Result<Option<Suggestion>> { | |
+ |row, keyword_prefix, keyword_suffix| -> Result<Option<Suggestion>> { | |
let suggestion_id: i64 = row.get("id")?; | |
let title = row.get("title")?; | |
let raw_url = row.get::<_, String>("url")?; | |
@@ -573,13 +571,11 @@ impl<'a> SuggestDao<'a> { | |
/// Fetches suggestions for MDN | |
pub fn fetch_mdn_suggestions(&self, query: &SuggestionQuery) -> Result<Vec<Suggestion>> { | |
- let keyword_lowercased = &query.keyword.to_lowercase(); | |
- let (_, keyword_suffix) = split_keyword(keyword_lowercased); | |
let suggestions = self | |
.map_prefix_keywords( | |
query, | |
&SuggestionProvider::Mdn, | |
- |row| -> Result<Option<Suggestion>> { | |
+ |row, keyword_prefix, keyword_suffix| -> Result<Option<Suggestion>> { | |
let suggestion_id: i64 = row.get("id")?; | |
let title = row.get("title")?; | |
let raw_url = row.get::<_, String>("url")?; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment