mirror of
https://github.com/InsanusMokrassar/PlaguPoster.git
synced 2024-12-22 22:17:14 +00:00
fixes
This commit is contained in:
parent
2e7a1b83c5
commit
dc5833c407
@ -43,7 +43,7 @@ class CachedPostsRepo(
|
|||||||
return null
|
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
|
package dev.inmo.plaguposter.ratings.source.buttons
|
||||||
|
|
||||||
import com.soywiz.klock.DateFormat
|
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.coroutines.runCatchingSafely
|
||||||
import dev.inmo.micro_utils.pagination.FirstPagePagination
|
import dev.inmo.micro_utils.pagination.FirstPagePagination
|
||||||
import dev.inmo.micro_utils.pagination.Pagination
|
import dev.inmo.micro_utils.pagination.Pagination
|
||||||
@ -63,6 +66,7 @@ suspend fun RatingsRepo.buildRatingButtons(
|
|||||||
postCreationTimeFormat: DateFormat = defaultPostCreationTimeFormat
|
postCreationTimeFormat: DateFormat = defaultPostCreationTimeFormat
|
||||||
): InlineKeyboardMarkup {
|
): InlineKeyboardMarkup {
|
||||||
val postsByRatings = getPosts(rating .. rating, true).keys.paginate(pagination)
|
val postsByRatings = getPosts(rating .. rating, true).keys.paginate(pagination)
|
||||||
|
TagLogger("RatingsButtonsBuilder").i { postsByRatings.results }
|
||||||
return inlineKeyboard {
|
return inlineKeyboard {
|
||||||
if (postsByRatings.pagesNumber > 1) {
|
if (postsByRatings.pagesNumber > 1) {
|
||||||
row {
|
row {
|
||||||
@ -75,7 +79,7 @@ suspend fun RatingsRepo.buildRatingButtons(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
postsByRatings.results.chunked(rowSize).map {
|
postsByRatings.results.chunked(rowSize).forEach {
|
||||||
row {
|
row {
|
||||||
it.forEach { postId ->
|
it.forEach { postId ->
|
||||||
val firstMessageInfo = postsRepo.getFirstMessageInfo(postId) ?: return@forEach
|
val firstMessageInfo = postsRepo.getFirstMessageInfo(postId) ?: return@forEach
|
||||||
|
@ -24,7 +24,7 @@ class CachedRatingsRepo(
|
|||||||
doForAllWithNextPaging {
|
doForAllWithNextPaging {
|
||||||
kvCache.keys(it).also {
|
kvCache.keys(it).also {
|
||||||
it.results.forEach {
|
it.results.forEach {
|
||||||
val rating = kvCache.get(it) ?: return@forEach
|
val rating = get(it) ?: return@forEach
|
||||||
if (it !in exclude && rating in range) {
|
if (it !in exclude && rating in range) {
|
||||||
result[it] = rating
|
result[it] = rating
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user