update sql in batch (#24801)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: -LAN- <laipz8200@outlook.com>
This commit is contained in:
parent
b51c724a94
commit
cbc0e639e4
49 changed files with 281 additions and 277 deletions
|
|
@ -6,6 +6,7 @@ from concurrent.futures import ThreadPoolExecutor
|
|||
|
||||
import click
|
||||
from flask import Flask, current_app
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.orm import Session, sessionmaker
|
||||
|
||||
from configs import dify_config
|
||||
|
|
@ -115,7 +116,7 @@ class ClearFreePlanTenantExpiredLogs:
|
|||
@classmethod
|
||||
def process_tenant(cls, flask_app: Flask, tenant_id: str, days: int, batch: int):
|
||||
with flask_app.app_context():
|
||||
apps = db.session.query(App).where(App.tenant_id == tenant_id).all()
|
||||
apps = db.session.scalars(select(App).where(App.tenant_id == tenant_id)).all()
|
||||
app_ids = [app.id for app in apps]
|
||||
while True:
|
||||
with Session(db.engine).no_autoflush as session:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue