1
0
mirror of https://github.com/wulkanowy/wulkanowy.git synced 2024-11-23 12:06:13 -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) gradeRepository.getGrades(student, semester, forceRefresh)
}.map { originalResource -> }.map { originalResource ->
val filteredSubjectWithGrades = originalResource.data?.first.orEmpty() val filteredSubjectWithGrades = originalResource.data?.first
.filter { grade -> .orEmpty()
grade.date.isAfter(LocalDate.now().minusDays(7)) .filter { it.date >= LocalDate.now().minusDays(7) }
} .groupBy { it.subject }
.groupBy { grade -> grade.subject }
.mapValues { entry -> .mapValues { entry ->
entry.value entry.value
.take(5) .take(5)
.sortedBy { grade -> grade.date } .sortedByDescending { it.date }
} }
.toList() .toList()
.sortedBy { subjectWithGrades -> subjectWithGrades.second[0].date } .sortedByDescending { (_, grades) -> grades[0].date }
.toMap() .toMap()
Resource( Resource(
@ -431,9 +430,9 @@ class DashboardPresenter @Inject constructor(
}.map { homeworkResource -> }.map { homeworkResource ->
val currentDate = LocalDate.now() val currentDate = LocalDate.now()
val filteredHomework = homeworkResource.data?.filter { val filteredHomework = homeworkResource.data
(it.date.isAfter(currentDate) || it.date == currentDate) && !it.isDone ?.filter { (it.date.isAfter(currentDate) || it.date == currentDate) && !it.isDone }
} ?.sortedBy { it.date }
homeworkResource.copy(data = filteredHomework) homeworkResource.copy(data = filteredHomework)
}.onEach { }.onEach {