-
Notifications
You must be signed in to change notification settings - Fork 473
Issue #8690: Specify the frecency threshold for the fetched top frecent sites #8806
Conversation
3a96f27
to
2d07c10
Compare
This pull request has conflicts when rebasing. Could you fix it @gabrielluong? 🙏 |
@@ -67,7 +68,8 @@ class DefaultTopSitesStorage( | |||
|
|||
override suspend fun getTopSites( | |||
totalSites: Int, | |||
includeFrecent: Boolean | |||
includeFrecent: Boolean, | |||
frecencyThreshold: FrecencyThresholdOption |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this option change? Maybe just put it in the constructor or leave it internal as part of our implicit feature expectations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't change, but we also fetch the option from the TopSiteConfig
2d07c10
to
f5bb79a
Compare
bf2583e
to
d96e557
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this looks good! I think we should simplify the APIs a bit to avoid having illegal combinations around, and make sure to separately test the a-s bump (I'd prefer that in a separate PR, actually).
components/browser/storage-sync/src/main/java/mozilla/components/browser/storage/sync/Types.kt
Show resolved
Hide resolved
components/concept/storage/src/main/java/mozilla/components/concept/storage/HistoryStorage.kt
Outdated
Show resolved
Hide resolved
components/concept/storage/src/main/java/mozilla/components/concept/storage/HistoryStorage.kt
Outdated
Show resolved
Hide resolved
components/concept/storage/src/main/java/mozilla/components/concept/storage/HistoryStorage.kt
Outdated
Show resolved
Hide resolved
...nents/feature/top-sites/src/main/java/mozilla/components/feature/top/sites/TopSitesConfig.kt
Outdated
Show resolved
Hide resolved
...ents/feature/top-sites/src/main/java/mozilla/components/feature/top/sites/TopSitesStorage.kt
Outdated
Show resolved
Hide resolved
d96e557
to
72713b6
Compare
7b76a38
to
5da0d86
Compare
This pull request has conflicts when rebasing. Could you fix it @gabrielluong? 🙏 |
5da0d86
to
e24dc47
Compare
This pull request has conflicts when rebasing. Could you fix it @gabrielluong? 🙏 |
e24dc47
to
5efb5c7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Just some nits and random musings.
🚢🚢🚢
...age-memory/src/main/java/mozilla/components/browser/storage/memory/InMemoryHistoryStorage.kt
Outdated
Show resolved
Hide resolved
...age-memory/src/main/java/mozilla/components/browser/storage/memory/InMemoryHistoryStorage.kt
Outdated
Show resolved
Hide resolved
components/browser/storage-sync/src/main/java/mozilla/components/browser/storage/sync/Types.kt
Show resolved
Hide resolved
...e/top-sites/src/test/java/mozilla/components/feature/top/sites/DefaultTopSitesStorageTest.kt
Show resolved
Hide resolved
@gabrielluong i'll do a round of testing for the a-s version bump before we land this. |
5efb5c7
to
18aeb2b
Compare
This pull request has conflicts when rebasing. Could you fix it @gabrielluong? 🙏 |
18aeb2b
to
609934f
Compare
This pull request has conflicts when rebasing. Could you fix it @gabrielluong? 🙏 |
609934f
to
4fe04e3
Compare
This pull request has conflicts when rebasing. Could you fix it @gabrielluong? 🙏 |
4fe04e3
to
391c20e
Compare
assertEquals(5, infos.size) | ||
assertEquals("https://www.mozilla.com/foo/bar/baz", infos[0].url) | ||
assertEquals("https://www.example.com/123", infos[1].url) | ||
assertEquals("https://news.ycombinator.com/", infos[2].url) | ||
assertEquals("https://mozilla.com/a1/b2/c3", infos[3].url) | ||
assertEquals("https://www.example.com/12345", infos[4].url) | ||
|
||
infos = history.getTopFrecentSites(100, frecencyThreshold = FrecencyThresholdOption.SKIP_ONE_TIME_PAGES) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will it work with negative values? e.g. history.getTopFrecentSites(-4, frecencyThreshold = FrecencyThresholdOption.NONE)
Textbook unit test :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added
if (numItems <= 0) {
return emptyList()
}
but I am wondering if we would prefer doing a require(numItems >= 0)
@@ -213,15 +215,15 @@ class DefaultTopSitesStorageTest { | |||
|
|||
val frecentSite2 = TopFrecentSiteInfo("https://example.com", "Example") | |||
val frecentSite3 = TopFrecentSiteInfo("https://getpocket.com", "Pocket") | |||
whenever(historyStorage.getTopFrecentSites(anyInt())).thenReturn( | |||
whenever(historyStorage.getTopFrecentSites(anyInt(), any())).thenReturn( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really recommend doing away with the mocks, and just using the real storage implementation instead. It's a little bit more working setting things up, but really not much more - you'd need to actually insert history items and visits yourself to prep the storage.
For an example of how to set this up, see browser-storage-sync
component. Specifically, you may need to copy-paste some bits from build.gradle
:
// These dependencies are part of this module's public API.
api(Dependencies.mozilla_places) {
// Use our own version of the Glean dependency,
// which might be different from the version declared by A-S.
exclude group: 'org.mozilla.components', module: 'service-glean'
}
...
testImplementation Dependencies.mozilla_places
testImplementation Dependencies.mozilla_full_megazord_forUnitTests
testImplementation Dependencies.mozilla_glean_forUnitTests
...
(it may work without the glean stuff, try that first; i don't recall the details right now)
The result should be a much more robust and useful test suite which exercises our whole stack! This will become a good integration test, instead of a "we're calling the right APIs" unit test. The latter is helpful, but the former actually gives you confidence that the system is working correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I spent some time on this, but ran into some issues that I have not managed to figure out yet. I will spin this task into a new issue #9501 to not block this any further.
This pull request has conflicts when rebasing. Could you fix it @gabrielluong? 🙏 |
391c20e
to
a217d15
Compare
Codecov Report
@@ Coverage Diff @@
## master #8806 +/- ##
============================================
- Coverage 74.57% 71.75% -2.82%
+ Complexity 5958 1957 -4001
============================================
Files 811 313 -498
Lines 29606 9662 -19944
Branches 4882 1630 -3252
============================================
- Hits 22078 6933 -15145
+ Misses 5055 1908 -3147
+ Partials 2473 821 -1652
Continue to review full report at Codecov.
|
…ched top frecent sites
a217d15
to
bca8f9b
Compare
4f710ce
to
bca8f9b
Compare
Fixes #8690. Requires AS bump with mozilla/application-services#3645.
Pull Request checklist
After merge