mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-05-17 07:21:58 +00:00
ref: increase watch threshold
This commit is contained in:
parent
d433a5cab4
commit
fa7c8068b3
2 changed files with 9 additions and 20 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue