bito-code-review[bot] commented on code in PR #40645:
URL: https://github.com/apache/superset/pull/40645#discussion_r3338752742


##########
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 as a naive UTC datetime (no tzinfo), so compute
+        # the cutoff with utcnow() to avoid a naive/aware mismatch that raises
+        # on PostgreSQL ("operator does not exist: timestamp without time 
zone").
         select_stmt = sa.select(Log.id).where(
-            Log.dttm < datetime.now() - 
timedelta(days=self.retention_period_days)
+            Log.dttm < datetime.utcnow() - 
timedelta(days=self.retention_period_days)
         )

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Deprecated datetime.utcnow() usage</b></div>
   <div id="fix">
   
   Replace deprecated `datetime.utcnow()` with `datetime.now(datetime.UTC)` for 
timezone-aware datetime handling. Also add missing trailing comma after the 
closing parenthesis.
   </div>
   
   
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ````suggestion
           select_stmt = sa.select(Log.id).where(
               Log.dttm < datetime.now(datetime.UTC) - 
timedelta(days=self.retention_period_days),
           )
   ````
   
   </div>
   </details>
   
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #528b2e</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



-- 
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