Skip to content

Commit

Permalink
Change currency rates update interval to 8 hours
Browse files Browse the repository at this point in the history
  • Loading branch information
mdrlzy committed Sep 20, 2024
1 parent 8ac27ad commit 5129e94
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import kotlinx.coroutines.sync.withLock
import kotlinx.coroutines.withContext
import java.time.Duration
import java.time.OffsetDateTime
import java.util.concurrent.TimeUnit
import javax.inject.Inject
import javax.inject.Singleton

Expand Down Expand Up @@ -96,7 +95,7 @@ class CurrencyRepoImpl @Inject constructor(
private fun hasUpdateIntervalPassed(updatedDate: OffsetDateTime?) =
updatedDate == null ||
Duration.between(updatedDate, OffsetDateTime.now())
.toMillis() > dayInMillis
.toMillis() > updateInterval

private val dayInMillis = TimeUnit.DAYS.toMillis(1)
private val updateInterval = Duration.ofHours(8).toMillis()
}

0 comments on commit 5129e94

Please sign in to comment.