Skip to content

Commit 4d8478d

Browse files
committed
improves sentences cleanup logging
Signed-off-by: Julien Buret <jburet@voyages-sncf.com>
1 parent 1da8a25 commit 4d8478d

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

nlp/front/storage-mongo/src/main/kotlin/ClassifiedSentenceMongoDAO.kt

+5-6
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ import org.litote.kmongo.regex
9191
import org.litote.kmongo.replaceOneWithFilter
9292
import org.litote.kmongo.setTo
9393
import org.litote.kmongo.setValue
94-
import org.litote.kmongo.toId
9594
import org.litote.kmongo.updateMany
9695
import java.time.Duration
9796
import java.time.Instant
@@ -206,16 +205,16 @@ internal object ClassifiedSentenceMongoDAO : ClassifiedSentenceDAO {
206205

207206
if (ttlIntents.isNotEmpty() && ttlDays != -1L) {
208207
logger.info { "add classified sentence periodic crawler for $ttlDays days and intents $ttlIntents" }
209-
injector.provide<Executor>().setPeriodic(Duration.ofDays(1)) {
210-
logger.debug { "delete old classified sentences for intents $ttlIntents" }
208+
injector.provide<Executor>().setPeriodic(Duration.ofMinutes(1), Duration.ofDays(1)) {
211209
val intentIds = IntentDefinitionMongoDAO.getIntentsByNames(ttlIntents).map { it._id }
212-
c.deleteMany(
210+
val deleted = c.deleteMany(
213211
and(
214212
Status eq inbox,
215213
Classification_.intentId `in` intentIds,
216214
UpdateDate lt now().minus(ttlDays, ChronoUnit.DAYS)
217215
)
218216
)
217+
logger.debug { "delete ${deleted.deletedCount} old classified sentences for intents $ttlIntents of ids $intentIds" }
219218
}
220219
}
221220

@@ -406,10 +405,10 @@ internal object ClassifiedSentenceMongoDAO : ClassifiedSentenceDAO {
406405
private fun SentencesQuery.filterLanguage() = if (language == null) null else Language eq language
407406

408407
private fun SentencesQuery.filterMaxIntentProbability(): Bson? =
409-
if (maxIntentProbability < 1f) LastIntentProbability lt maxIntentProbability.toDouble() else null
408+
if (maxIntentProbability < 1f) LastIntentProbability lt maxIntentProbability.toDouble() else null
410409

411410
private fun SentencesQuery.filterMinIntentProbability(): Bson? =
412-
if (minIntentProbability > 0f) LastIntentProbability gt minIntentProbability.toDouble() else null
411+
if (minIntentProbability > 0f) LastIntentProbability gt minIntentProbability.toDouble() else null
413412

414413
//ugly
415414
private fun subEntityTypeQuery(entityType: String): Bson =

0 commit comments

Comments
 (0)