complete timer plugin

This commit is contained in:
2022-12-14 11:50:02 +06:00
parent c632a2ba14
commit b9c78982b5
22 changed files with 304 additions and 52 deletions

View File

@@ -101,6 +101,7 @@ object Plugin : Plugin {
}
val post = postsRepo.getById(postId) ?: return false
ratingsRepo.set(postId, Rating(0.0))
for (content in post.content) {
runCatchingSafely {
val sent = send(
@@ -140,7 +141,7 @@ object Plugin : Plugin {
}
}
postsRepo.deletedObjectsIdsFlow.subscribeSafelyWithoutExceptions(this) { postId ->
ratingsRepo.onValueRemoved.subscribeSafelyWithoutExceptions(this) { postId ->
detachPoll(postId)
}

View File

@@ -1,6 +1,7 @@
package dev.inmo.plaguposter.ratings.exposed
import dev.inmo.micro_utils.pagination.utils.optionallyReverse
import dev.inmo.micro_utils.repos.exposed.initTable
import dev.inmo.micro_utils.repos.exposed.keyvalue.AbstractExposedKeyValueRepo
import dev.inmo.plaguposter.posts.models.PostId
import dev.inmo.plaguposter.ratings.models.Rating
@@ -24,6 +25,10 @@ class ExposedRatingsRepo (
override val ResultRow.asObject: Rating
get() = get(ratingsColumn).let(::Rating)
init {
initTable()
}
override fun update(k: PostId, v: Rating, it: UpdateBuilder<Int>) {
it[ratingsColumn] = v.double
}