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:
parent
17563d1a4b
commit
68fdb167c2
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user