Skip to content

Commit

Permalink
test: 코루틴 테스트용 커밋 - withContext
Browse files Browse the repository at this point in the history
  • Loading branch information
belljun3395 committed Jan 13, 2025
1 parent 7298120 commit 5add285
Showing 1 changed file with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.few.api.repo.dao.article.ArticleViewCountDao
import com.few.api.repo.dao.article.query.SelectArticlesOrderByViewsQuery
import com.few.api.repo.dao.article.query.SelectRankByViewsQuery
import com.few.api.repo.dao.article.record.ArticleMainCardRecord
import com.few.api.repo.dao.article.record.SelectArticleContentsRecord
import com.few.api.repo.dao.article.record.SelectArticleViewsRecord
import com.few.data.common.code.CategoryType
import kotlinx.coroutines.*
Expand Down Expand Up @@ -58,25 +59,25 @@ class BrowseArticlesUseCase(
true
}

// val recordViewIds = articleViewsRecords.map { it.articleId }.toSet()
// val articleMainCardRecords = recordViewIds.map { articleMainCardDao.selectArticleMainCardsRecordAsync(it)!! }.toSet()
// val deferredResults = mutableListOf<SelectArticleContentsRecord>()
// recordViewIds.map { id ->
// withContext(Dispatchers.IO) {
// articleDao.selectArticleContentsAsync(id)
// }
// }

val recordViewIds = articleViewsRecords.map { it.articleId }.toSet()
val deferredResults =
recordViewIds.map { id ->
val articleMainCardRecord = articleMainCardDao.selectArticleMainCardsRecordAsync(id)
val selectArticleContentsRecord = articleDao.selectArticleContentsAsync(id)
articleMainCardRecord.apply {
this.content = selectArticleContentsRecord.content
}
val articleMainCardRecords = recordViewIds.map { articleMainCardDao.selectArticleMainCardsRecordAsync(it)!! }.toSet()
val deferredResults = mutableListOf<SelectArticleContentsRecord>()
recordViewIds.map { id ->
withContext(Dispatchers.IO) {
articleDao.selectArticleContentsAsync(id)
}
val articleMainCardRecords = deferredResults.toMutableSet()
}

// val recordViewIds = articleViewsRecords.map { it.articleId }.toSet()
// val deferredResults =
// recordViewIds.map { id ->
// val articleMainCardRecord = articleMainCardDao.selectArticleMainCardsRecordAsync(id)
// val selectArticleContentsRecord = articleDao.selectArticleContentsAsync(id)
// articleMainCardRecord.apply {
// this.content = selectArticleContentsRecord.content
// }
// }
// val articleMainCardRecords = deferredResults.toMutableSet()
// val coroutineScope = CoroutineScope(Dispatchers.IO)
// val recordViewIds = articleViewsRecords.map { it.articleId }.toSet()
// val deferredResults = mutableListOf<Deferred<ArticleMainCardRecord>>()
Expand Down

0 comments on commit 5add285

Please sign in to comment.