forked from github/wulkanowy-mirror
Fix grade sorting (#825)
This commit is contained in:
parent
d558c4db66
commit
c3a6f8253a
@ -171,10 +171,13 @@ class GradeDetailsPresenter @Inject constructor(
|
||||
}
|
||||
|
||||
private fun createGradeItems(items: List<GradeDetailsWithAverage>): List<GradeDetailsItem> {
|
||||
return items.filter { it.grades.isNotEmpty() }.map { (subject, average, points, _, grades) ->
|
||||
val subItems = grades.map {
|
||||
GradeDetailsItem(it, ViewType.ITEM)
|
||||
}
|
||||
return items
|
||||
.filter { it.grades.isNotEmpty() }
|
||||
.sortedBy { it.subject }
|
||||
.map { (subject, average, points, _, grades) ->
|
||||
val subItems = grades
|
||||
.sortedByDescending { it.date }
|
||||
.map { GradeDetailsItem(it, ViewType.ITEM) }
|
||||
|
||||
listOf(GradeDetailsItem(GradeDetailsHeader(
|
||||
subject = subject,
|
||||
|
@ -103,14 +103,8 @@ class GradeSummaryPresenter @Inject constructor(
|
||||
}
|
||||
|
||||
private fun createGradeSummaryItems(items: List<GradeDetailsWithAverage>): List<GradeSummary> {
|
||||
return items.map {
|
||||
it.summary.copy(average = it.average)
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkEmpty(gradeSummary: GradeSummary, averages: List<Triple<String, Double, String>>): Boolean {
|
||||
return gradeSummary.run {
|
||||
finalGrade.isBlank() && predictedGrade.isBlank() && averages.singleOrNull { it.first == subject } == null
|
||||
}
|
||||
return items
|
||||
.sortedBy { it.subject }
|
||||
.map { it.summary.copy(average = it.average) }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user