add selector

This commit is contained in:
2022-09-06 23:56:58 +06:00
parent cf5a4c0f61
commit f3f7761bf9
16 changed files with 361 additions and 17 deletions

View File

@@ -7,4 +7,6 @@ import kotlin.jvm.JvmInline
@JvmInline
value class Rating(
val double: Double
)
) : Comparable<Rating> {
override fun compareTo(other: Rating): Int = double.compareTo(other.double)
}

View File

@@ -4,4 +4,24 @@ import dev.inmo.micro_utils.repos.ReadKeyValueRepo
import dev.inmo.plaguposter.posts.models.PostId
import dev.inmo.plaguposter.ratings.models.Rating
interface ReadRatingsRepo : ReadKeyValueRepo<PostId, Rating>
interface ReadRatingsRepo : ReadKeyValueRepo<PostId, Rating> {
suspend fun getPosts(
range: ClosedRange<Rating>,
reversed: Boolean = false,
count: Int? = null,
exclude: List<PostId> = emptyList()
): Map<PostId, Rating>
suspend fun getPostsWithRatingGreaterEq(
then: Rating,
reversed: Boolean = false,
count: Int? = null,
exclude: List<PostId> = emptyList()
): Map<PostId, Rating>
suspend fun getPostsWithRatingLessEq(
then: Rating,
reversed: Boolean = false,
count: Int? = null,
exclude: List<PostId> = emptyList()
): Map<PostId, Rating>
}