group_id INT NOT NULL REFERENCES groups(group_id) ON DELETE CASCADE,
pos INT default 0,
name VARCHAR,
- update_interval INT
+ update_interval INT,
+ auto_mark_read BOOLEAN DEFAULT FALSE
)
""".trimIndent())
feed_id INT NOT NULL REFERENCES feeds(feed_id),
title VARCHAR NOT NULL,
link VARCHAR NOT NULL,
+ category VARCHAR,
description CLOB,
author VARCHAR,
pub_date TIMESTAMP,
guid VARCHAR UNIQUE,
contentText CLOB,
- contentHTML CLOB
+ contentHTML CLOB,
+ is_read BOOLEAN DEFAULT FALSE,
+ is_bookmarked BOOLEAN DEFAULT FALSE
)
""".trimIndent())
g.group_id,
g.name as group_name,
f.feedcollection_id,
- f.name as feed_name
+ f.name as feed_name,
+ f.update_interval,
+ f.auto_mark_read
from groups g
left join feedcollections f on g.group_id = f.group_id
order by g.pos, f.pos
val groupName = rs.getString("group_name")
val feedId = rs.getInt("feedcollection_id")
val feedName = rs.getString("feed_name")
+ val updateInterval = rs.getLong("update_interval")
+ val autoMarkRead = rs.getBoolean("auto_mark_read")
if(currentGroup == null || currentGroup.id != groupId) {
currentGroup = FeedGroup(context, groupId, groupName)
}
if(feedId != null && feedName != null) {
- currentGroup.feeds.add(FeedCollection(feedId, feedName))
+ val feed = FeedCollection(feedId, feedName)
+ feed.updateInterval = updateInterval
+ feed.autoMarkRead = autoMarkRead
+ currentGroup.feeds.add(feed)
}
}
item.feedId = rs.getInt("feed_id")
item.title = rs.getString("title")
item.link = rs.getString("link")
+ item.category = rs.getString("category")
item.description = rs.getString("description")
item.author = rs.getString("author")
item.pubDate = rs.getObject("pub_date", java.time.LocalDateTime::class.java)
item.contentHtml = rs.getString("contentHTML")
item.feedName = feedCollection.name
item.feedUrl = rs.getString("URL")
+ item.isRead = rs.getBoolean("is_read")
+ item.isBookmark = rs.getBoolean("is_bookmarked")
items.add(item)
}
}
public fun addItems(items: Collection<Item>) {
dataSource.connection.use { conn ->
conn.prepareStatement("""
- insert into items (feed_id, title, link, description, author, pub_date, guid, contentText, contentHTML)
- select ?, ?, ?, ?, ?, ?, ?, ?, ?
+ insert into items (feed_id, title, link, category, description, author, pub_date, guid, contentText, contentHTML)
+ select ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
where ? not in (select guid from items)
""".trimIndent()).use { stmt ->
items.forEach { item ->
stmt.setInt(1, item.feedId)
stmt.setString(2, item.title)
stmt.setString(3, item.link)
- stmt.setString(4, item.description)
- stmt.setString(5, item.author)
- stmt.setTimestamp(6, item.pubDate?.let { java.sql.Timestamp.valueOf(it) })
- stmt.setString(7, item.guid)
- stmt.setString(8, item.contentText)
- stmt.setString(9, item.contentHtml)
- stmt.setString(10, item.guid)
+ stmt.setString(4, item.category)
+ stmt.setString(5, item.description)
+ stmt.setString(6, item.author)
+ stmt.setTimestamp(7, item.pubDate?.let { java.sql.Timestamp.valueOf(it) })
+ stmt.setString(8, item.guid)
+ stmt.setString(9, item.contentText)
+ stmt.setString(10, item.contentHtml)
+ stmt.setString(11, item.guid)
stmt.addBatch()
}
stmt.executeBatch()