Add suspend to getOneOff* read queries

recent_search
Takeshi Hagikura 2 years ago
parent 333a248327
commit 0c6e542555

@ -54,10 +54,10 @@ class DefaultSearchContentsRepository @Inject constructor(
val newsResourceIds = newsResourceFtsDao.searchAllNewsResources("*$searchQuery*")
val topicIds = topicFtsDao.searchAllTopics("*$searchQuery*")
return combine(newsResourceIds, topicIds) { news, topics ->
return combine(newsResourceIds, topicIds) { newsFlow, topicsFlow ->
combine(
newsResourceDao.getNewsResources(filterNewsIds = news.toSet()),
topicDao.getTopicEntities(topics.toSet()),
newsResourceDao.getNewsResources(filterNewsIds = newsFlow.toSet()),
topicDao.getTopicEntities(topicsFlow.toSet()),
) { newsResources, topics ->
SearchResult(
topics = topics.map { it.asExternalModel() },

@ -68,7 +68,7 @@ interface NewsResourceDao {
@Transaction
@Query(value = "SELECT * FROM news_resources ORDER BY publish_date DESC")
fun getOneOffNewsResources(): List<PopulatedNewsResource>
suspend fun getOneOffNewsResources(): List<PopulatedNewsResource>
/**
* Inserts [entities] into the db if they don't exist, and ignores those that do

@ -42,7 +42,7 @@ interface TopicDao {
fun getTopicEntities(): Flow<List<TopicEntity>>
@Query(value = "SELECT * FROM topics")
fun getOneOffTopicEntities(): List<TopicEntity>
suspend fun getOneOffTopicEntities(): List<TopicEntity>
@Query(
value = """

Loading…
Cancel
Save