Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit de7c1659 authored by Guillaume Jacquart's avatar Guillaume Jacquart
Browse files

fix: sentry: Crash when geenrating reports with empty trackers database.

parent 67b57bb1
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -110,7 +110,12 @@ class WeeklyReportUseCase(

    private suspend fun addCallPerAppCandidates(candidates: MutableList<WeeklyReport>, endOfWeek: Instant) {
        val startOfWeek = getStartOfWeek(endOfWeek)
        val (appIdWithMostCalls, callsPerWeek) = statsDatabase.getCallsByAppIds(startOfWeek, endOfWeek).maxBy { it.value }
        val callsByAppIds = statsDatabase.getCallsByAppIds(startOfWeek, endOfWeek)
        if (callsByAppIds.isEmpty()) {
            return
        }

        val (appIdWithMostCalls, callsPerWeek) = callsByAppIds.maxBy { it.value }
        val app = appListRepository.getAppById(appIdWithMostCalls)?.id

        // TODO: get second one on fail ?