From 182dd42b3a9919374c2411ada8040f23d078d8e7 Mon Sep 17 00:00:00 2001 From: Olaf Wintermann Date: Thu, 4 Sep 2025 17:05:15 +0200 Subject: [PATCH] add Database.getPendingFeeds --- .../kotlin/de/unixwork/rssreader/Database.kt | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/rss-application/src/main/kotlin/de/unixwork/rssreader/Database.kt b/rss-application/src/main/kotlin/de/unixwork/rssreader/Database.kt index 1808577..b1ab08f 100644 --- a/rss-application/src/main/kotlin/de/unixwork/rssreader/Database.kt +++ b/rss-application/src/main/kotlin/de/unixwork/rssreader/Database.kt @@ -274,6 +274,32 @@ object Database { return feeds } + public fun getPendingFeeds() : MutableList { + val feeds = mutableListOf() + + dataSource.connection.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 60 end + """.trimIndent()).use { stmt -> + stmt.executeQuery().use { rs -> + val id = rs.getInt("feed_id") + val feedCollectionId = rs.getInt("feedcollection_id") + val url = rs.getString("url") + val authUser = rs.getString("auth_user") + val authPassword = rs.getString("auth_password") + val certPath = rs.getString("certpath") + val feed = Feed(id, feedCollectionId, url) + feed.user = authUser + feed.password = authPassword + feed.certpath = certPath + feeds.add(feed) + } + } + + return feeds + } + public fun addItems(items: Collection) { dataSource.connection.use { conn -> conn.prepareStatement(""" -- 2.47.3