Skip to content

Commit

Permalink
Remove debug/test logs
Browse files Browse the repository at this point in the history
  • Loading branch information
CrisBarreiro committed Nov 8, 2024
1 parent 5a9aa05 commit 91ca637
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import com.squareup.anvil.annotations.ContributesBinding
import dagger.SingleInstanceIn
import java.time.LocalDateTime
import javax.inject.Inject
import timber.log.Timber

interface BrokenSitePromptInMemoryStore {
fun resetRefreshCount()
Expand Down Expand Up @@ -62,7 +61,6 @@ class RealBrokenSitePromptInMemoryStore @Inject constructor() : BrokenSitePrompt
return refreshes?.let {
val time = it.time.filter { time -> time.isAfter(t1) && time.isBefore(t2) }
refreshes = it.copy(time = time)
Timber.d("Cris. $refreshes")
time.size
} ?: 0
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import com.duckduckgo.common.utils.CurrentTimeProvider
import com.duckduckgo.di.scopes.AppScope
import com.squareup.anvil.annotations.ContributesBinding
import javax.inject.Inject
import timber.log.Timber

@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
internal const val REFRESH_COUNT_WINDOW = 20L
Expand All @@ -44,17 +43,13 @@ class RealBrokenSitePrompt @Inject constructor(

override suspend fun userDismissedPrompt() {
if (!_featureEnabled) return
Timber.d("Cris. Dismiss streak: ${brokenSiteReportRepository.getDismissStreak()}")
if (brokenSiteReportRepository.getDismissStreak() >= brokenSiteReportRepository.getMaxDismissStreak() - 1) {
brokenSiteReportRepository.resetDismissStreak()
val nextShownDate = brokenSiteReportRepository.getNextShownDate()
val newNextShownDate = currentTimeProvider.localDateTimeNow().plusDays(brokenSiteReportRepository.getDismissStreakResetDays().toLong())

if (nextShownDate == null || newNextShownDate.isAfter(nextShownDate)) {
brokenSiteReportRepository.setNextShownDate(newNextShownDate)
Timber.d("Cris. Dismiss. New next shown date: $newNextShownDate")
} else {
Timber.d("Cris. Dismiss. Next shown date not updated to $newNextShownDate, keeping existing value: $nextShownDate")
}
} else {
brokenSiteReportRepository.incrementDismissStreak()
Expand Down Expand Up @@ -104,9 +99,6 @@ class RealBrokenSitePrompt @Inject constructor(
val newNextShownDate = currentTimeProvider.localDateTimeNow().plusDays(brokenSiteReportRepository.getCoolDownDays())
if (nextShownDate == null || newNextShownDate.isAfter(nextShownDate)) {
brokenSiteReportRepository.setNextShownDate(newNextShownDate)
Timber.d("Cris. Shown. New next shown date: $newNextShownDate")
} else {
Timber.d("Cris. Shown. Next shown date not updated to $newNextShownDate, keeping existing value: $nextShownDate")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class RealBrokenSitePromptTest {
@Test
fun whenUserDismissedPromptAndNoNextShownDateThenIncrementDismissStreakAndDoNotUpdateNextShownDate() = runTest {
whenever(mockBrokenSiteReportRepository.getNextShownDate()).thenReturn(null)
whenever(mockBrokenSiteReportRepository.getMaxDismissStreak()).thenReturn(3)
whenever(mockBrokenSiteReportRepository.getDismissStreak()).thenReturn(0)

testee.userDismissedPrompt()

Expand All @@ -69,10 +71,12 @@ class RealBrokenSitePromptTest {
}

@Test
fun whenUserDismissedPromptMaxDismissStreakTimesAndNextShownDateLaterThanCooldownDaysThenResetDismissStreakAndDoNotUpdateNextShownDate() =
fun whenUserDismissedPromptMaxDismissStreakTimesAndNextShownDateLaterThanDismissStreakDaysThenResetDismissStreakAndDoNotUpdateNextShownDate() =
runTest {
whenever(mockBrokenSiteReportRepository.getNextShownDate()).thenReturn(LocalDateTime.now().plusDays(11))
whenever(mockBrokenSiteReportRepository.getDismissStreak()).thenReturn(2)
whenever(mockBrokenSiteReportRepository.getMaxDismissStreak()).thenReturn(3)
whenever(mockBrokenSiteReportRepository.getDismissStreakResetDays()).thenReturn(2)
whenever(mockCurrentTimeProvider.localDateTimeNow()).thenReturn(LocalDateTime.now())

testee.userDismissedPrompt()
Expand Down

0 comments on commit 91ca637

Please sign in to comment.