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

Commit 91ce27ea authored by Guillaume Jacquart's avatar Guillaume Jacquart
Browse files

fix:3058: filter 0 calls per period weeklyreports

parent 0c7d9c04
Loading
Loading
Loading
Loading
Loading
+30 −25
Original line number Diff line number Diff line
@@ -119,14 +119,15 @@ class WeeklyReportUseCase(
            return
        }

        val hoursInWeek = 7 * 24
        val callsPerHours = callsPerWeek / (7 * 24)
        if (callsPerHours > 0) {
            candidates.add(
                WeeklyReport(
                    endOfWeek,
                    WeeklyReport.StatType.CALLS_PER_APP,
                    WeeklyReport.LabelId.CALLS_PER_APP_1,
                    app,
                listOf((callsPerWeek / hoursInWeek).toString())
                    listOf(callsPerHours.toString())
                )
            )

@@ -136,20 +137,24 @@ class WeeklyReportUseCase(
                    WeeklyReport.StatType.CALLS_PER_APP,
                    WeeklyReport.LabelId.CALLS_PER_APP_2,
                    app,
                listOf((callsPerWeek / hoursInWeek).toString())
                    listOf(callsPerHours.toString())
                )
            )
        }

        val callsPerDay = callsPerWeek / 7
        if (callsPerDay > 0) {
            candidates.add(
                WeeklyReport(
                    endOfWeek,
                    WeeklyReport.StatType.CALLS_PER_APP,
                    WeeklyReport.LabelId.CALLS_PER_APP_3,
                    app,
                listOf((callsPerWeek / 7).toString())
                    listOf((callsPerDay).toString())
                )
            )
        }
    }

    private suspend fun addNewTrackerCandidates(candidates: MutableList<WeeklyReport>, endOfWeek: Instant) = withContext(Dispatchers.IO) {
        val startOfWeek = getStartOfWeek(endOfWeek)