SkipDays ignore previously entered entries

pull/2012/head
Dharanish 1 year ago
parent efdf216323
commit 81f85a77fa

@ -91,17 +91,24 @@ open class EntryList {
open fun recomputeFrom(
originalEntries: EntryList,
frequency: Frequency,
isNumerical: Boolean
isNumerical: Boolean,
skipDays: SkipDays = SkipDays.NONE
) {
clear()
val original = originalEntries.getKnown()
if (isNumerical) {
original.forEach { add(it) }
original.filter { !skipDays.isDaySkipped(it.timestamp) }.forEach { add(it) }
} else {
val intervals = buildIntervals(frequency, original)
snapIntervalsTogether(intervals)
val computed = buildEntriesFromInterval(original, intervals)
computed.filter { it.value != UNKNOWN || it.notes.isNotEmpty() }.forEach { add(it) }
computed
.filter {
!skipDays.isDaySkipped(it.timestamp) &&
it.value != UNKNOWN ||
it.notes.isNotEmpty()
}
.forEach { add(it) }
}
}

@ -79,7 +79,8 @@ data class Habit(
computedEntries.recomputeFrom(
originalEntries = originalEntries,
frequency = frequency,
isNumerical = isNumerical
isNumerical = isNumerical,
skipDays = skipDays
)
val today = DateUtils.getTodayWithOffset()

@ -78,7 +78,7 @@ class SQLiteEntryList(database: Database) : EntryList() {
return super.getKnown()
}
override fun recomputeFrom(originalEntries: EntryList, frequency: Frequency, isNumerical: Boolean) {
override fun recomputeFrom(originalEntries: EntryList, frequency: Frequency, isNumerical: Boolean, skipDays: SkipDays) {
throw UnsupportedOperationException()
}

Loading…
Cancel
Save