val defaultUpdateInterval: UiInteger
val minUpdateWaitTime: UiInteger
val autoUpdateStartDelay: UiInteger
+ val maxItemAge: UiInteger
val message: UiString
defaultUpdateInterval = window.ui.integer()
minUpdateWaitTime = window.ui.integer()
autoUpdateStartDelay = window.ui.integer()
+ maxItemAge = window.ui.integer()
message = window.ui.string()
}
row {
- rlabel("Default Update Interval")
+ rlabel("Default Update Interval (Seconds)")
spinbox(intValue = defaultUpdateInterval, min = 0.0, max = 1000000.0)
}
row {
- rlabel("Minimum Update Wait Time")
+ rlabel("Minimum Update Wait Time (Seconds)")
spinbox(intValue = minUpdateWaitTime, min = 0.0, max = 1000000.0)
}
row {
- rlabel("Auto Update Start Delay")
+ rlabel("Auto Update Start Delay (Seconds)")
spinbox(intValue = autoUpdateStartDelay, min = 0.0, max = 1000000.0)
}
+
+ row {
+ rlabel("Max Item Age (Days)")
+ spinbox(intValue = maxItemAge, min = 0.0, max = 200000.0)
+ }
}
grid(margin = 12, rowspacing = 12) {
row {
defaultUpdateInterval.setIntValue(App.settings.defaultRefreshInterval)
minUpdateWaitTime.setIntValue(App.settings.minRefreshWaitTime)
autoUpdateStartDelay.setIntValue(App.settings.autoRefreshStartDelay)
+ maxItemAge.setIntValue(App.settings.maxItemAge)
}
fun save() {
App.settings.defaultRefreshInterval = defaultUpdateInterval.intValue()
App.settings.minRefreshWaitTime = minUpdateWaitTime.intValue()
App.settings.autoRefreshStartDelay = autoUpdateStartDelay.intValue()
+ App.settings.maxItemAge = maxItemAge.intValue()
}
fun show() {
pos INT default 0,
name VARCHAR,
update_interval INT,
+ max_item_age INT DEFAULT 0,
item_state_mode INT DEFAULT 0
)
""".trimIndent())
}
return seconds
}
+
+ public fun cleanupItems(defaultMaxItemAge: Int) {
+ dataSource.connection.use { conn ->
+ conn.prepareStatement("""
+ delete from items where item_id in (
+ select item_id
+ from (select i.item_id,
+ c.name,
+ f.feed_id,
+ c.max_item_age,
+ datediff('dd', coalesce(updated, pub_date), now()) as age,
+ case when c.max_item_age > 0 then c.max_item_age else ? end as max_age
+ from items i
+ inner join feeds f on i.feed_id = f.feed_id
+ inner join feedcollections c on f.feedcollection_id = c.feedcollection_id
+ where i.is_bookmarked = false
+ and c.max_item_age >= 0)
+ where age > max_age
+ )
+ """.trimIndent()).use { stmt ->
+ stmt.setInt(1, defaultMaxItemAge)
+ stmt.execute()
+ }
+ }
+ }
}
var autoRefreshStartDelay = 10
var defaultRefreshInterval = 3600
var minRefreshWaitTime = 60
+ var maxItemAge = 0
fun load() {
val filePath = Toolkit.getConfigFilePath("rssreader.properties")
e.printStackTrace()
}
}
+ val maxItemAge = properties.getProperty("MaxItemAge")
+ maxItemAge?.let {
+ try {
+ this.maxItemAge = it.toInt()
+ } catch (e: NumberFormatException) {}
+ }
} else {
println("create new file: $filePath")
store(file)
AutoRefreshStartDelay = $autoRefreshStartDelay
DefaultRefreshInterval = $defaultRefreshInterval
MinRefreshWaitTime = $minRefreshWaitTime
+ MaxItemAge = $maxItemAge
""".trimIndent())
}
}
\ No newline at end of file