From 06a4aff46e7ae2f9736d0e9384386b9be9454632 Mon Sep 17 00:00:00 2001 From: Jordi Mas Date: Tue, 7 May 2024 13:36:27 +0200 Subject: [PATCH] Fix date --- transcribe-batch/tests/testusage.py | 4 +--- transcribe-service/usage.py | 5 ++--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/transcribe-batch/tests/testusage.py b/transcribe-batch/tests/testusage.py index 41e8d79..1468ab4 100644 --- a/transcribe-batch/tests/testusage.py +++ b/transcribe-batch/tests/testusage.py @@ -70,9 +70,7 @@ def test_log_rotate(self): usage.log("conversion_error") lines = self.readLog() - print(lines) - - self.assertEqual(len(lines), 2) + self.assertEqual(len(lines), 1) def _test_is_old_line_true(self): usage = UsageTest() diff --git a/transcribe-service/usage.py b/transcribe-service/usage.py index 409b574..cb705f0 100755 --- a/transcribe-service/usage.py +++ b/transcribe-service/usage.py @@ -114,9 +114,8 @@ def _is_old_line(self, line): logging.error("Usage._is_old_line. Error:" + str(exception)) invalid = True - return invalid or line_datetime < self._get_time_now() - datetime.timedelta( - days=self.DAYS_TO_KEEP - ) + now = self._get_time_now() - datetime.timedelta(days=self.DAYS_TO_KEEP) + return invalid or line_datetime.date() <= now.date() def _rotate_file(self): NEW = "usage.new"