declan-zhao commented on code in PR #36313:
URL: https://github.com/apache/superset/pull/36313#discussion_r2582561490
##########
superset/commands/logs/prune.py:
##########
@@ -55,18 +61,16 @@ def run(self) -> None:
total_deleted = 0
start_time = time.time()
- # Select all IDs that need to be deleted
- ids_to_delete = (
- db.session.execute(
- sa.select(Log.id).where(
- Log.dttm
- < datetime.now() -
timedelta(days=self.retention_period_days)
- )
- )
- .scalars()
- .all()
+ # Select IDs to delete, optionally limited by max_rows_per_run
+ select_stmt = sa.select(Log.id).where(
+ Log.dttm < datetime.now() -
timedelta(days=self.retention_period_days)
)
+ if self.max_rows_per_run is not None and self.max_rows_per_run > 0:
+ select_stmt = select_stmt.limit(self.max_rows_per_run)
Review Comment:
Added `order_by` clause
--
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]