This commit is contained in:
InsanusMokrassar 2022-09-09 18:17:02 +06:00
parent 7549286c84
commit 4c9b6e485f
3 changed files with 10 additions and 7 deletions

View File

@ -97,7 +97,9 @@ class ExposedPostsRepo(
}
}
override fun insert(value: NewPost, it: InsertStatement<Number>) {}
override fun insert(value: NewPost, it: InsertStatement<Number>) {
it[createdColumn] = DateTime.now().unixMillis
}
override suspend fun deleteById(ids: List<PostId>) {
onBeforeDelete(ids)

View File

@ -6,8 +6,7 @@ import dev.inmo.krontab.KrontabTemplate
import dev.inmo.krontab.toSchedule
import dev.inmo.krontab.utils.asFlow
import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions
import dev.inmo.micro_utils.repos.deleteById
import dev.inmo.micro_utils.repos.id
import dev.inmo.micro_utils.repos.*
import dev.inmo.plagubot.Plugin
import dev.inmo.plaguposter.posts.repo.PostsRepo
import dev.inmo.plaguposter.ratings.models.Rating
@ -45,7 +44,9 @@ object Plugin : Plugin {
config.immediateDrop ?.let { toDrop ->
ratingsRepo.onNewValue.subscribeSafelyWithoutExceptions(this) {
postsRepo.deleteById(it.id)
if (it.value <= toDrop) {
postsRepo.deleteById(it.id)
}
}
}
config.autoclear ?.let { autoclear ->

View File

@ -21,9 +21,9 @@ import kotlinx.serialization.encoding.Encoder
@Serializable
data class RatingConfig(
val min: Rating?,
val max: Rating?,
val prefer: Prefer,
val min: Rating? = null,
val max: Rating? = null,
val prefer: Prefer = Prefer.Random,
val otherwise: RatingConfig? = null,
val postAge: Seconds? = null
) {