From fa7c8068b3050d9fd8ac09673da09b7b674cad41 Mon Sep 17 00:00:00 2001 From: tapframe <85391825+tapframe@users.noreply.github.com> Date: Tue, 5 May 2026 12:06:14 +0530 Subject: [PATCH] ref: increase watch threshold --- .../watching/domain/WatchingPolicies.kt | 17 +++-------------- .../watchprogress/WatchProgressRulesTest.kt | 12 ++++++------ 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/watching/domain/WatchingPolicies.kt b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/watching/domain/WatchingPolicies.kt index 27c6fcd1..0612a6b5 100644 --- a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/watching/domain/WatchingPolicies.kt +++ b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/watching/domain/WatchingPolicies.kt @@ -1,8 +1,7 @@ package com.nuvio.app.features.watching.domain -private const val InProgressStartThresholdFraction = 0.02f -private const val CompletionThresholdFraction = 0.85 -private const val InProgressStartThresholdMinMs = 30_000L +private const val CompletionThresholdFraction = 0.90 +private const val ProgressStoreThresholdMs = 1_000L private const val UpcomingNextSeasonWindowDays = 7 fun watchedKey( @@ -14,17 +13,7 @@ fun watchedKey( fun shouldStoreProgress( positionMs: Long, durationMs: Long, -): Boolean { - val thresholdMs = if (durationMs > 0L) { - maxOf( - InProgressStartThresholdMinMs, - (durationMs * InProgressStartThresholdFraction).toLong(), - ) - } else { - 1L - } - return positionMs >= thresholdMs -} +): Boolean = positionMs >= ProgressStoreThresholdMs fun isProgressComplete( positionMs: Long, diff --git a/composeApp/src/commonTest/kotlin/com/nuvio/app/features/watchprogress/WatchProgressRulesTest.kt b/composeApp/src/commonTest/kotlin/com/nuvio/app/features/watchprogress/WatchProgressRulesTest.kt index d07261fd..658bdb66 100644 --- a/composeApp/src/commonTest/kotlin/com/nuvio/app/features/watchprogress/WatchProgressRulesTest.kt +++ b/composeApp/src/commonTest/kotlin/com/nuvio/app/features/watchprogress/WatchProgressRulesTest.kt @@ -26,17 +26,17 @@ class WatchProgressRulesTest { } @Test - fun `save threshold uses max of thirty seconds and two percent`() { - assertFalse(shouldStoreWatchProgress(positionMs = 29_999L, durationMs = 600_000L)) - assertTrue(shouldStoreWatchProgress(positionMs = 30_000L, durationMs = 600_000L)) - assertFalse(shouldStoreWatchProgress(positionMs = 119_999L, durationMs = 6_000_000L)) - assertTrue(shouldStoreWatchProgress(positionMs = 120_000L, durationMs = 6_000_000L)) + fun `save threshold starts after one second`() { + assertFalse(shouldStoreWatchProgress(positionMs = 999L, durationMs = 600_000L)) + assertTrue(shouldStoreWatchProgress(positionMs = 1_000L, durationMs = 600_000L)) + assertTrue(shouldStoreWatchProgress(positionMs = 1_000L, durationMs = 0L)) } @Test fun `completion detects watched threshold remaining time and ended state`() { assertTrue(isWatchProgressComplete(positionMs = 920_000L, durationMs = 1_000_000L, isEnded = false)) - assertTrue(isWatchProgressComplete(positionMs = 850_000L, durationMs = 1_000_000L, isEnded = false)) + assertTrue(isWatchProgressComplete(positionMs = 900_000L, durationMs = 1_000_000L, isEnded = false)) + assertFalse(isWatchProgressComplete(positionMs = 899_999L, durationMs = 1_000_000L, isEnded = false)) assertTrue(isWatchProgressComplete(positionMs = 1L, durationMs = 0L, isEnded = true)) assertFalse(isWatchProgressComplete(positionMs = 200_000L, durationMs = 1_000_000L, isEnded = false)) }