Skip to content

Commit

Permalink
🚑️ Fix critical nullpointer exception
Browse files Browse the repository at this point in the history
Signed-off-by: Leonardo Colman Lopes <[email protected]>
  • Loading branch information
LeoColman committed Dec 29, 2024
1 parent 25b4ec4 commit a70279d
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import br.com.colman.petals.statistics.graph.formatter.GramsValueFormatter
import br.com.colman.petals.use.repository.Use
import com.github.mikephil.charting.data.Entry
import com.github.mikephil.charting.data.LineDataSet
import java.math.BigDecimal
import java.time.LocalDate.now

@Composable
Expand Down Expand Up @@ -41,7 +42,7 @@ private fun calculateAllTimeGramsDistribution(uses: List<Use>): List<Entry> {
val lastUseDay = now().toEpochDay()

return (firstUseDay..lastUseDay).map { day ->
val totalGrams = usesByDay[day]!!.sumOf { it.amountGrams }
val totalGrams = usesByDay[day]?.sumOf { it.amountGrams } ?: BigDecimal.ZERO
Entry((day - firstUseDay).toFloat(), totalGrams.toFloat())
}
}
Expand Down

0 comments on commit a70279d

Please sign in to comment.