diff --git a/posts/src/jvmMain/kotlin/cached/CachedPostsRepo.kt b/posts/src/jvmMain/kotlin/cached/CachedPostsRepo.kt index 305f310..1d69be4 100644 --- a/posts/src/jvmMain/kotlin/cached/CachedPostsRepo.kt +++ b/posts/src/jvmMain/kotlin/cached/CachedPostsRepo.kt @@ -43,7 +43,7 @@ class CachedPostsRepo( return null } - override suspend fun getPostCreationTime(postId: PostId): DateTime? = kvCache.get(postId) ?.created + override suspend fun getPostCreationTime(postId: PostId): DateTime? = getById(postId) ?.created - override suspend fun getFirstMessageInfo(postId: PostId): PostContentInfo? = kvCache.get(postId) ?.content ?.firstOrNull() + override suspend fun getFirstMessageInfo(postId: PostId): PostContentInfo? = getById(postId) ?.content ?.firstOrNull() } diff --git a/ratings/source/src/commonMain/kotlin/buttons/RootButtons.kt b/ratings/source/src/commonMain/kotlin/buttons/RootButtons.kt index 606d398..8931da9 100644 --- a/ratings/source/src/commonMain/kotlin/buttons/RootButtons.kt +++ b/ratings/source/src/commonMain/kotlin/buttons/RootButtons.kt @@ -1,6 +1,9 @@ package dev.inmo.plaguposter.ratings.source.buttons import com.soywiz.klock.DateFormat +import dev.inmo.kslog.common.TagLogger +import dev.inmo.kslog.common.d +import dev.inmo.kslog.common.i import dev.inmo.micro_utils.coroutines.runCatchingSafely import dev.inmo.micro_utils.pagination.FirstPagePagination import dev.inmo.micro_utils.pagination.Pagination @@ -63,6 +66,7 @@ suspend fun RatingsRepo.buildRatingButtons( postCreationTimeFormat: DateFormat = defaultPostCreationTimeFormat ): InlineKeyboardMarkup { val postsByRatings = getPosts(rating .. rating, true).keys.paginate(pagination) + TagLogger("RatingsButtonsBuilder").i { postsByRatings.results } return inlineKeyboard { if (postsByRatings.pagesNumber > 1) { row { @@ -75,7 +79,7 @@ suspend fun RatingsRepo.buildRatingButtons( } } } - postsByRatings.results.chunked(rowSize).map { + postsByRatings.results.chunked(rowSize).forEach { row { it.forEach { postId -> val firstMessageInfo = postsRepo.getFirstMessageInfo(postId) ?: return@forEach diff --git a/ratings/src/commonMain/kotlin/repo/CachedRatingsRepo.kt b/ratings/src/commonMain/kotlin/repo/CachedRatingsRepo.kt index 115efbd..ab3e1e8 100644 --- a/ratings/src/commonMain/kotlin/repo/CachedRatingsRepo.kt +++ b/ratings/src/commonMain/kotlin/repo/CachedRatingsRepo.kt @@ -24,7 +24,7 @@ class CachedRatingsRepo( doForAllWithNextPaging { kvCache.keys(it).also { it.results.forEach { - val rating = kvCache.get(it) ?: return@forEach + val rating = get(it) ?: return@forEach if (it !in exclude && rating in range) { result[it] = rating }