fix in plugin of ratings gc

This commit is contained in:
InsanusMokrassar 2024-05-13 19:36:09 +06:00
parent 69320a3b62
commit 0f958f94cb
2 changed files with 7 additions and 1 deletions

View File

@ -2,6 +2,10 @@
## 0.5.6 ## 0.5.6
* `Ratings`:
* `GC`:
* Now GC will autoclear ratings even if post is absent in posts repo
## 0.5.5 ## 0.5.5
* Dependencies update * Dependencies update

View File

@ -62,7 +62,9 @@ object Plugin : Plugin {
suspend fun doAutoClear() { suspend fun doAutoClear() {
val dropCreatedBefore = DateTime.now() - (autoclear.skipPostAge ?: 0).seconds val dropCreatedBefore = DateTime.now() - (autoclear.skipPostAge ?: 0).seconds
ratingsRepo.getPostsWithRatingLessEq(autoclear.rating).keys.forEach { ratingsRepo.getPostsWithRatingLessEq(autoclear.rating).keys.forEach {
if ((postsRepo.getPostCreationTime(it) ?: return@forEach) < dropCreatedBefore) { val postCreationDateTime = postsRepo.getPostCreationTime(it) ?: (dropCreatedBefore - 1.seconds) // do dropping if post creation time is not available
if (postCreationDateTime < dropCreatedBefore) {
ratingsRepo.unset(it)
postsRepo.deleteById(it) postsRepo.deleteById(it)
} }
} }