Skip to content

Commit

Permalink
Update DownloadStatsInterface.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
gdams authored Aug 23, 2023
1 parent 7bb8573 commit c8d4b39
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class DownloadStatsInterface {
}

suspend fun getTrackingStats(
var days: Int? = null,
days: Int? = null,
from: ZonedDateTime? = null,
to: ZonedDateTime? = null,
source: StatsSource? = null,
Expand All @@ -47,12 +47,14 @@ class DownloadStatsInterface {
jvmImpl: JvmImpl? = null
): List<DownloadDiff> {

// If to and from are set set days
if (to != null && from != null) {
days = ChronoUnit.DAYS.between(from, to).toInt()
// If to and from are set days
val daysSince = if (to != null && from != null) {
ChronoUnit.DAYS.between(from, to).toInt() + 1
} else {
// need +1 as for a diff you need num days +1 from db
(days ?: 30) + 1
}

// need +1 as for a diff you need num days +1 from db

val daysSince = (days ?: 30) + 1
val statsSource = source ?: StatsSource.all
val periodEnd = to ?: TimeSource.now()
Expand Down

0 comments on commit c8d4b39

Please sign in to comment.