]> uap-core.de Git - rssreader.git/commitdiff
add Database.getPendingFeeds
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Thu, 4 Sep 2025 15:05:15 +0000 (17:05 +0200)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Thu, 4 Sep 2025 15:05:15 +0000 (17:05 +0200)
rss-application/src/main/kotlin/de/unixwork/rssreader/Database.kt

index 18085772451fafa497025d64f3331ddf581b99f8..b1ab08f85c438620c0f35693dfbd291dd0b4d0ae 100644 (file)
@@ -274,6 +274,32 @@ object Database {
         return feeds
     }
 
+    public fun getPendingFeeds() : MutableList<Feed> {
+        val feeds = mutableListOf<Feed>()
+
+        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<Item>) {
         dataSource.connection.use { conn ->
             conn.prepareStatement("""