MainActivity: generate dynamic menu from last two weeks

This commit is contained in:
2026-02-19 00:12:45 +01:00
parent 80d8d317f4
commit 895162a284

View File

@@ -148,10 +148,12 @@ class MainActivity : AppCompatActivity() {
val eventTypeStats = mutableMapOf<LunaEvent.Type, Int>() val eventTypeStats = mutableMapOf<LunaEvent.Type, Int>()
if (dynamicMenu) { if (dynamicMenu) {
val sampleSize = 100 // populate frequency map from all events of the last two weeks
// populate frequency map from first 100 events val lastWeekTime = (System.currentTimeMillis() / 1000) - (14 * 24 * 60 * 60)
allEvents.take(sampleSize.coerceAtMost(allEvents.size)).forEach { allEvents.forEach {
eventTypeStats[it.type] = 1 + (eventTypeStats[it.type] ?: 0) if (it.time > lastWeekTime) {
eventTypeStats[it.type] = 1 + (eventTypeStats[it.type] ?: 0)
}
} }
} }