[fenix] No issue: Remove showHistorySearchGroups feature flag

pull/600/head
Roger Yang 3 years ago committed by mergify[bot]
parent 463028b353
commit 96d0dfae36

@ -63,11 +63,6 @@ object FeatureFlags {
*/
val tabReorderingFeature = Config.channel.isNightlyOrDebug
/**
* Enables showing search groupings in the History.
*/
const val showHistorySearchGroups = true
/**
* Show Pocket recommended stories on home.
*/

@ -89,7 +89,6 @@ interface PagedHistoryProvider {
*/
class DefaultPagedHistoryProvider(
private val historyStorage: PlacesHistoryStorage,
private val showHistorySearchGroups: Boolean = FeatureFlags.showHistorySearchGroups,
private val historyImprovementFeatures: Boolean = FeatureFlags.historyImprovementFeatures,
) : PagedHistoryProvider {
@ -131,53 +130,32 @@ class DefaultPagedHistoryProvider(
// A PagedList DataSource runs on a background thread automatically.
// If we run this in our own coroutineScope it breaks the PagedList
runBlockingIncrement {
var history: List<HistoryDB>
if (showHistorySearchGroups) {
// We need to re-fetch all the history metadata if the offset resets back at 0
// in the case of a pull to refresh.
if (historyGroups == null || offset == 0) {
historyGroups = historyStorage.getHistoryMetadataSince(Long.MIN_VALUE)
.asSequence()
.sortedByDescending { it.createdAt }
.filter { it.key.searchTerm != null }
.groupBy { it.key.searchTerm!! }
.map { (searchTerm, items) ->
HistoryDB.Group(
title = searchTerm,
visitedAt = items.first().createdAt,
items = items.map { it.toHistoryDBMetadata() }
)
// We need to re-fetch all the history metadata if the offset resets back at 0
// in the case of a pull to refresh.
if (historyGroups == null || offset == 0) {
historyGroups = historyStorage.getHistoryMetadataSince(Long.MIN_VALUE)
.asSequence()
.sortedByDescending { it.createdAt }
.filter { it.key.searchTerm != null }
.groupBy { it.key.searchTerm!! }
.map { (searchTerm, items) ->
HistoryDB.Group(
title = searchTerm,
visitedAt = items.first().createdAt,
items = items.map { it.toHistoryDBMetadata() }
)
}
.filter {
if (historyImprovementFeatures) {
it.items.size >= SEARCH_GROUP_MINIMUM_SITES
} else {
true
}
.filter {
if (historyImprovementFeatures) {
it.items.size >= SEARCH_GROUP_MINIMUM_SITES
} else {
true
}
}
.toList()
}
history = getHistoryAndSearchGroups(offset, numberOfItems)
} else {
history = historyStorage
.getVisitsPaginated(
offset.toLong(),
numberOfItems.toLong(),
excludeTypes = excludedVisitTypes
)
.map { transformVisitInfoToHistoryItem(it) }
.distinctBy { Pair(it.historyTimeGroup, it.url) }
if (historyImprovementFeatures) {
history = history.distinctBy { Pair(it.historyTimeGroup, it.url) }
.filter { !urlSet[it.historyTimeGroup.ordinal].contains(it.url) }
history.map { urlSet[it.historyTimeGroup.ordinal].add(it.url) }
}
}
.toList()
}
onComplete(history)
onComplete(getHistoryAndSearchGroups(offset, numberOfItems))
}
}

@ -30,8 +30,7 @@ class PagedHistoryProviderTest {
fun `getHistory uses getVisitsPaginated`() {
val provider = DefaultPagedHistoryProvider(
historyStorage = storage,
showHistorySearchGroups = true,
false
historyImprovementFeatures = false,
)
val visitInfo1 = VisitInfo(
@ -148,8 +147,7 @@ class PagedHistoryProviderTest {
fun `history metadata matching lower bound`() {
val provider = DefaultPagedHistoryProvider(
historyStorage = storage,
showHistorySearchGroups = true,
false
historyImprovementFeatures = false,
)
// Oldest history visit on the page is 15 seconds (buffer time) newer than matching
// metadata record.
@ -221,8 +219,7 @@ class PagedHistoryProviderTest {
fun `history metadata matching upper bound`() {
val provider = DefaultPagedHistoryProvider(
historyStorage = storage,
showHistorySearchGroups = true,
false
historyImprovementFeatures = false,
)
// Newest history visit on the page is 15 seconds (buffer time) older than matching
// metadata record.
@ -294,8 +291,7 @@ class PagedHistoryProviderTest {
fun `redirects are filtered out from history metadata groups`() {
val provider = DefaultPagedHistoryProvider(
historyStorage = storage,
showHistorySearchGroups = true,
false
historyImprovementFeatures = false,
)
val visitInfo1 = VisitInfo(

Loading…
Cancel
Save