|
|
|
@ -24,6 +24,13 @@ fun List<List<QueryCondition>>.upToNow(): List<List<QueryCondition>> { |
|
|
|
val currentYear = calendar.get(Calendar.YEAR) |
|
|
|
val currentYear = calendar.get(Calendar.YEAR) |
|
|
|
val currentMonth = calendar.get(Calendar.MONTH) |
|
|
|
val currentMonth = calendar.get(Calendar.MONTH) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val realm = Realm.getDefaultInstance() |
|
|
|
|
|
|
|
val firstSession = realm.where<Session>().sort("year", Sort.ASCENDING).findFirst() |
|
|
|
|
|
|
|
realm.close() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val firstYear = firstSession?.year ?: currentYear |
|
|
|
|
|
|
|
val firstMonth = firstSession?.month ?: currentMonth |
|
|
|
|
|
|
|
|
|
|
|
val toRemove = this.filter { list -> |
|
|
|
val toRemove = this.filter { list -> |
|
|
|
list.any { it is QueryCondition.AnyYear && it.listOfValues.first() == currentYear } |
|
|
|
list.any { it is QueryCondition.AnyYear && it.listOfValues.first() == currentYear } |
|
|
|
}.filter { list -> |
|
|
|
}.filter { list -> |
|
|
|
@ -32,6 +39,14 @@ fun List<List<QueryCondition>>.upToNow(): List<List<QueryCondition>> { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val toRemoveBefore = this.filter { list -> |
|
|
|
|
|
|
|
list.any { it is QueryCondition.AnyYear && it.listOfValues.first() == firstYear } |
|
|
|
|
|
|
|
}.filter { list -> |
|
|
|
|
|
|
|
list.any { |
|
|
|
|
|
|
|
it is QueryCondition.AnyMonthOfYear && it.listOfValues.first() < firstMonth |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return this.filter{ list -> |
|
|
|
return this.filter{ list -> |
|
|
|
var keep = true |
|
|
|
var keep = true |
|
|
|
toRemove.forEach { |
|
|
|
toRemove.forEach { |
|
|
|
@ -39,6 +54,13 @@ fun List<List<QueryCondition>>.upToNow(): List<List<QueryCondition>> { |
|
|
|
keep = false |
|
|
|
keep = false |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
firstSession?.let { |
|
|
|
|
|
|
|
toRemoveBefore.forEach { |
|
|
|
|
|
|
|
if (list.containsAll(it)) { |
|
|
|
|
|
|
|
keep = false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
keep |
|
|
|
keep |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|