1
0
mirror of https://github.com/wulkanowy/wulkanowy.git synced 2024-11-23 11:56:09 -06:00

Sort items in homework and grade tiles on the dashboard (#1634)

This commit is contained in:
Rafał Borcz 2021-11-15 22:35:01 +01:00 committed by GitHub
parent 17563d1a4b
commit 68fdb167c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -316,18 +316,17 @@ class DashboardPresenter @Inject constructor(
gradeRepository.getGrades(student, semester, forceRefresh)
}.map { originalResource ->
val filteredSubjectWithGrades = originalResource.data?.first.orEmpty()
.filter { grade ->
grade.date.isAfter(LocalDate.now().minusDays(7))
}
.groupBy { grade -> grade.subject }
val filteredSubjectWithGrades = originalResource.data?.first
.orEmpty()
.filter { it.date >= LocalDate.now().minusDays(7) }
.groupBy { it.subject }
.mapValues { entry ->
entry.value
.take(5)
.sortedBy { grade -> grade.date }
.sortedByDescending { it.date }
}
.toList()
.sortedBy { subjectWithGrades -> subjectWithGrades.second[0].date }
.sortedByDescending { (_, grades) -> grades[0].date }
.toMap()
Resource(
@ -431,9 +430,9 @@ class DashboardPresenter @Inject constructor(
}.map { homeworkResource ->
val currentDate = LocalDate.now()
val filteredHomework = homeworkResource.data?.filter {
(it.date.isAfter(currentDate) || it.date == currentDate) && !it.isDone
}
val filteredHomework = homeworkResource.data
?.filter { (it.date.isAfter(currentDate) || it.date == currentDate) && !it.isDone }
?.sortedBy { it.date }
homeworkResource.copy(data = filteredHomework)
}.onEach {