rusackas commented on code in PR #40645:
URL: https://github.com/apache/superset/pull/40645#discussion_r3338076159


##########
superset/commands/logs/prune.py:
##########
@@ -64,8 +64,11 @@ def run(self) -> None:
         start_time = time.time()
 
         # Select all IDs that need to be deleted
+        # Log.dttm is stored in UTC, so compute the cutoff in UTC as well to
+        # keep retention correct regardless of the server's local timezone.
         select_stmt = sa.select(Log.id).where(
-            Log.dttm < datetime.now() - 
timedelta(days=self.retention_period_days)
+            Log.dttm
+            < datetime.now(tz=timezone.utc) - 
timedelta(days=self.retention_period_days)

Review Comment:
   Fixed — switched from `datetime.now(tz=timezone.utc)` to `datetime.utcnow()` 
in `LogPruneCommand`. `Log.dttm` is stored as a naive UTC datetime 
(`default=datetime.utcnow`), so comparing with an aware datetime would raise a 
type error on PostgreSQL. The test was updated to assert `cutoff.tzinfo is 
None`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to