--- a/app/src/main/java/com/geekorum/ttrss/articles_list/ArticlesRepository.kt Tue Nov 09 22:09:00 2021 -0400
+++ b/app/src/main/java/com/geekorum/ttrss/articles_list/ArticlesRepository.kt Thu Nov 11 17:52:37 2021 -0400
@@ -56,6 +56,10 @@
return articleDao.getAllUnreadArticlesOldestFirst()
}
+ suspend fun getUnreadArticlesRandomized(count: Int): List<ArticleWithFeed> {
+ return articleDao.getUnreadArticlesRandomized(count)
+ }
+
fun getAllPublishedArticles(): PagingSource<Int, ArticleWithFeed> = articleDao.getAllPublishedArticles()
fun getAllPublishedArticlesOldestFirst(): PagingSource<Int, ArticleWithFeed> = articleDao.getAllPublishedArticlesOldestFirst()
@@ -78,6 +82,10 @@
return articleDao.getAllUnreadArticlesForFeedOldestFirst(feedId)
}
+ suspend fun getAllUnreadArticlesForFeedUpdatedAfterTimeRandomized(feedId: Long, time: Long): List<Article> {
+ return articleDao.getAllUnreadArticlesForFeedUpdatedAfterTimeRandomized(feedId, time)
+ }
+
fun getAllArticlesForTag(tag: String): PagingSource<Int, ArticleWithFeed> = articleDao.getAllArticlesForTag(tag)
fun getAllArticlesForTagOldestFirst(tag: String): PagingSource<Int, ArticleWithFeed> = articleDao.getAllArticlesForTagOldestFirst(tag)
@@ -106,6 +114,10 @@
@OptIn(ExperimentalCoroutinesApi::class)
fun getArticleById(articleId: Long): Flow<Article?> = articleDao.getArticleById(articleId).distinctUntilChanged()
+ fun getArticlesById(articleIds: List<Long>): PagingSource<Int, ArticleWithFeed> {
+ return articleDao.getArticlesById(articleIds)
+ }
+
suspend fun setArticleUnread(articleId: Long, newValue: Boolean) {
articleDao.updateArticleUnread(articleId, newValue)
}
--- a/app/src/main/java/com/geekorum/ttrss/data/ArticleDao.kt Tue Nov 09 22:09:00 2021 -0400
+++ b/app/src/main/java/com/geekorum/ttrss/data/ArticleDao.kt Thu Nov 11 17:52:37 2021 -0400
@@ -34,6 +34,10 @@
@Query("SELECT * FROM articles WHERE _id=:id")
fun getArticleById(id: Long): Flow<Article?>
+ @Query("SELECT * FROM articles WHERE _id IN (:articleIds)")
+ @Transaction
+ fun getArticlesById(articleIds: List<Long>): PagingSource<Int, ArticleWithFeed>
+
@Query("SELECT * FROM articles ORDER BY last_time_update DESC")
@Transaction
fun getAllArticles(): PagingSource<Int, ArticleWithFeed>
@@ -48,6 +52,10 @@
@Transaction
fun getAllUnreadArticlesOldestFirst(): PagingSource<Int, ArticleWithFeed>
+ @Query("SELECT * FROM articles WHERE unread=1 ORDER BY RANDOM() LIMIT :count")
+ @Transaction
+ suspend fun getUnreadArticlesRandomized(count: Int): List<ArticleWithFeed>
+
@Query("SELECT * FROM articles WHERE feed_id=:feedId ORDER BY last_time_update DESC ")
@Transaction
fun getAllArticlesForFeed(feedId: Long): PagingSource<Int, ArticleWithFeed>
@@ -62,6 +70,11 @@
@Transaction
fun getAllUnreadArticlesForFeedOldestFirst(feedId: Long): PagingSource<Int, ArticleWithFeed>
+ @Query("SELECT * FROM articles WHERE last_time_update>=:time AND unread=1 AND feed_id=:feedId " +
+ "ORDER BY RANDOM()")
+ @Transaction
+ suspend fun getAllUnreadArticlesForFeedUpdatedAfterTimeRandomized(feedId: Long, time: Long): List<Article>
+
@Query("SELECT articles.* FROM articles " +
" JOIN articles_tags ON (articles_tags.article_id = articles._id)" +
" WHERE articles_tags.tag=:tag ORDER BY last_time_update DESC")