Filter out empty items in grade summary (#857)

This commit is contained in:
Mikołaj Pich 2020-06-02 01:01:02 +02:00 committed by GitHub
parent 5c0160a24d
commit d8d13c73fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -109,7 +109,17 @@ class GradeSummaryPresenter @Inject constructor(
private fun createGradeSummaryItems(items: List<GradeDetailsWithAverage>): List<GradeSummary> {
return items
.filter { !checkEmpty(it) }
.sortedBy { it.subject }
.map { it.summary.copy(average = it.average) }
}
private fun checkEmpty(gradeSummary: GradeDetailsWithAverage): Boolean {
return gradeSummary.run {
summary.finalGrade.isBlank()
&& summary.predictedGrade.isBlank()
&& average == .0
&& points == "-"
}
}
}