conn.prepareStatement("""
select f.* from feeds f
inner join feedcollections c on f.feedcollection_id = c.feedcollection_id
- where datediff(ss, coalesce(last_update, '1970-01-01'), now()) > case when c.update_interval > 0 then c.update_interval else ? end
+ where datediff(ss, coalesce(last_update, '1970-01-01'), now()) + 45 > case when c.update_interval > 0 then c.update_interval else ? end
""".trimIndent()).use { stmt ->
stmt.setInt(1, defaultInterval)
stmt.executeQuery().use { rs ->
dataSource.connection.use { conn ->
feed.lastUpdate = java.time.LocalDateTime.now()
conn.prepareStatement("""
- update feeds set last_update = ? where feed_id = ?
+ update feeds set last_update = now() where feed_id = ?
""".trimIndent()).use { stmt ->
- stmt.setTimestamp(1, java.sql.Timestamp.valueOf(feed.lastUpdate))
- stmt.setInt(2, feed.id)
+ stmt.setInt(1, feed.id)
stmt.execute()
}
}