mirror of
https://github.com/InsanusMokrassar/PlaguPoster.git
synced 2024-11-17 13:33:47 +00:00
fixes
This commit is contained in:
parent
2e7a1b83c5
commit
dc5833c407
@ -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()
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user