Skip to content

Commit

Permalink
🐛 Fix date range for statistics requests (#478)
Browse files Browse the repository at this point in the history
  • Loading branch information
jheubuch authored Jan 27, 2025
1 parent 7357825 commit 5a25518
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/src/main/kotlin/de/hbch/traewelling/api/ApiService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ interface AuthService {
interface StatisticsService {
@GET("statistics")
fun getPersonalStatistics(
@Query("from") from: LocalDate,
@Query("until") until: LocalDate
@Query("from") from: ZonedDateTime,
@Query("until") until: ZonedDateTime
): Call<Data<PersonalStatistics>>

@GET("statistics/daily/{date}?withPolylines=true")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ fun Statistics(
if (range != null) {
statisticsViewModel.getPersonalStatisticsForSelectedTimeRange()
dateRangePickerState.setSelection(
range.first.atStartOfDay(ZoneId.systemDefault()).toInstant().toEpochMilli(),
LocalDateTime.of(range.second, LocalTime.MAX).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()
range.first.atStartOfDay(ZoneId.of("UTC")).toInstant().toEpochMilli(),
LocalDateTime.of(range.second, LocalTime.MAX).atZone(ZoneId.of("UTC")).toInstant().toEpochMilli()
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
import java.time.LocalDate
import java.time.ZoneId

class StatisticsViewModel : ViewModel() {

Expand All @@ -34,8 +35,8 @@ class StatisticsViewModel : ViewModel() {
val range = dateRange.value ?: initDateRange()
dateRange.postValue(range)

val from = range.first
val until = range.second
val from = range.first.atStartOfDay(ZoneId.systemDefault())
val until = range.second.atStartOfDay(ZoneId.systemDefault()).withHour(23).withMinute(59).withSecond(59)

TraewellingApi
.statisticsService
Expand Down

0 comments on commit 5a25518

Please sign in to comment.