Skip to content

Commit

Permalink
increase number of various suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
akliuxingyuan committed Jan 20, 2024
1 parent 799063d commit 4b02488
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
1 change: 1 addition & 0 deletions automation/iceraven/patch_android_components.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ do
done

git -C android-components apply < automation/iceraven/patches/top_sites_no_most_visted_sites.patch
git -C android-components apply < automation/iceraven/patches/suggestions_increase_number.patch
61 changes: 61 additions & 0 deletions automation/iceraven/patches/suggestions_increase_number.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
diff --git a/components/feature/awesomebar/src/main/java/mozilla/components/feature/awesomebar/provider/BookmarksStorageSuggestionProvider.kt b/components/feature/awesomebar/src/main/java/mozilla/components/feature/awesomebar/provider/BookmarksStorageSuggestionProvider.kt
index 73252c1560..0544a51f59 100644
--- a/components/feature/awesomebar/src/main/java/mozilla/components/feature/awesomebar/provider/BookmarksStorageSuggestionProvider.kt
+++ b/components/feature/awesomebar/src/main/java/mozilla/components/feature/awesomebar/provider/BookmarksStorageSuggestionProvider.kt
@@ -86,7 +86,7 @@ class BookmarksStorageSuggestionProvider(
* @param query String to filter bookmarks' title or URL by.
*/
private suspend fun getBookmarksSuggestions(query: String) = bookmarksStorage
- .searchBookmarks(query, BOOKMARKS_SUGGESTION_LIMIT)
+ .searchBookmarks(query, BOOKMARKS_SUGGESTION_LIMIT * BOOKMARKS_RESULTS_TO_FILTER_SCALE_FACTOR)
.filter { it.url != null }
.distinctBy { it.url }
.sortedBy { it.guid }
diff --git a/components/feature/awesomebar/src/main/java/mozilla/components/feature/awesomebar/provider/CombinedHistorySuggestionProvider.kt b/components/feature/awesomebar/src/main/java/mozilla/components/feature/awesomebar/provider/CombinedHistorySuggestionProvider.kt
index 5d79e8caed..293a5cee78 100644
--- a/components/feature/awesomebar/src/main/java/mozilla/components/feature/awesomebar/provider/CombinedHistorySuggestionProvider.kt
+++ b/components/feature/awesomebar/src/main/java/mozilla/components/feature/awesomebar/provider/CombinedHistorySuggestionProvider.kt
@@ -145,7 +145,7 @@ class CombinedHistorySuggestionProvider(
* @param query String to filter bookmarks' title or URL by.
*/
private suspend fun getMetadataSuggestions(query: String) = historyMetadataStorage
- .queryHistoryMetadata(query, maxNumberOfSuggestions)
+ .queryHistoryMetadata(query, maxNumberOfSuggestions * COMBINED_HISTORY_RESULTS_TO_FILTER_SCALE_FACTOR)
.filter { it.totalViewTime > 0 }
.into(this@CombinedHistorySuggestionProvider, icons, loadUrlUseCase, showEditSuggestion)

@@ -169,7 +169,7 @@ class CombinedHistorySuggestionProvider(
* @param query String to filter history entry's title or URL by.
*/
private suspend fun getHistorySuggestions(query: String) = historyStorage
- .getSuggestions(query, maxNumberOfSuggestions)
+ .getSuggestions(query, maxNumberOfSuggestions * COMBINED_HISTORY_RESULTS_TO_FILTER_SCALE_FACTOR)
.sortedByDescending { it.score }
.distinctBy { it.id }
.into(this@CombinedHistorySuggestionProvider, icons, loadUrlUseCase, showEditSuggestion)
diff --git a/components/feature/awesomebar/src/main/java/mozilla/components/feature/awesomebar/provider/HistoryMetadataSuggestionProvider.kt b/components/feature/awesomebar/src/main/java/mozilla/components/feature/awesomebar/provider/HistoryMetadataSuggestionProvider.kt
index ad1d7590b7..512262ee9a 100644
--- a/components/feature/awesomebar/src/main/java/mozilla/components/feature/awesomebar/provider/HistoryMetadataSuggestionProvider.kt
+++ b/components/feature/awesomebar/src/main/java/mozilla/components/feature/awesomebar/provider/HistoryMetadataSuggestionProvider.kt
@@ -85,7 +85,7 @@ class HistoryMetadataSuggestionProvider(
* @param query String to filter history entry's title or URL by.
*/
private suspend fun getHistorySuggestions(query: String) = historyStorage
- .queryHistoryMetadata(query, maxNumberOfSuggestions)
+ .queryHistoryMetadata(query, maxNumberOfSuggestions * HISTORY_METADATA_RESULTS_TO_FILTER_SCALE_FACTOR)
.filter { it.totalViewTime > 0 }

/**
diff --git a/components/feature/awesomebar/src/main/java/mozilla/components/feature/awesomebar/provider/HistoryStorageSuggestionProvider.kt b/components/feature/awesomebar/src/main/java/mozilla/components/feature/awesomebar/provider/HistoryStorageSuggestionProvider.kt
index e9d56bede3..c95da08651 100644
--- a/components/feature/awesomebar/src/main/java/mozilla/components/feature/awesomebar/provider/HistoryStorageSuggestionProvider.kt
+++ b/components/feature/awesomebar/src/main/java/mozilla/components/feature/awesomebar/provider/HistoryStorageSuggestionProvider.kt
@@ -110,7 +110,7 @@ class HistoryStorageSuggestionProvider(
* @param query String to filter history entry's title or URL by.
*/
private fun getHistorySuggestions(query: String) = historyStorage
- .getSuggestions(query, maxNumberOfSuggestions)
+ .getSuggestions(query, maxNumberOfSuggestions * HISTORY_RESULTS_TO_FILTER_SCALE_FACTOR)
// In case of duplicates we want to pick the suggestion with the highest score.
// See: https://github.com/mozilla/application-services/issues/970
.sortedByDescending { it.score }

0 comments on commit 4b02488

Please sign in to comment.