style: 统一 Ruff 代码格式

This commit is contained in:
yml2213
2026-08-30 21:04:52 +08:00
parent c891ac982e
commit 47e19ed7b2
90 changed files with 5574 additions and 2350 deletions
+20 -5
View File
@@ -36,7 +36,10 @@ def _audit_log_out(db: Session, row: AuditLog) -> dict:
accounts = (
db.query(DouyuTask, Account)
.join(Account, Account.id == DouyuTask.account_id)
.filter(DouyuTask.batch_id == batch_id, DouyuTask.task_type == "create_gold_qr")
.filter(
DouyuTask.batch_id == batch_id,
DouyuTask.task_type == "create_gold_qr",
)
.order_by(DouyuTask.id.asc())
.limit(100)
.all()
@@ -56,14 +59,19 @@ def _audit_log_out(db: Session, row: AuditLog) -> dict:
batch_id = row.target.removeprefix("douyu_batch:")
task = (
db.query(DouyuTask)
.filter(DouyuTask.batch_id == batch_id, DouyuTask.task_type == "create_gold_qr")
.filter(
DouyuTask.batch_id == batch_id,
DouyuTask.task_type == "create_gold_qr",
)
.order_by(DouyuTask.id.asc())
.first()
)
task_result = task.result if task and isinstance(task.result, dict) else {}
recharge_channel = str(task_result.get("recharge_channel") or "wechat_qr")
detail["recharge_channel"] = recharge_channel
detail["payment_method"] = "API 直充支付" if recharge_channel == "supplier_api" else "微信扫码支付"
detail["payment_method"] = (
"API 直充支付" if recharge_channel == "supplier_api" else "微信扫码支付"
)
if isinstance(detail, dict):
detail_text = json.dumps(detail, ensure_ascii=False, separators=(",", ":"))
return {
@@ -99,7 +107,9 @@ def list_audit_logs(
query = query.filter(AuditLog.action == action.strip())
if keyword:
pattern = f"%{keyword.strip()}%"
query = query.filter((AuditLog.target.ilike(pattern)) | (AuditLog.detail.ilike(pattern)))
query = query.filter(
(AuditLog.target.ilike(pattern)) | (AuditLog.detail.ilike(pattern))
)
if success is not None:
query = query.filter(AuditLog.success == success)
if start_time:
@@ -107,7 +117,12 @@ def list_audit_logs(
if end_time:
query = query.filter(AuditLog.created_at <= end_time)
total = query.count()
rows = query.order_by(AuditLog.id.desc()).offset((page - 1) * page_size).limit(page_size).all()
rows = (
query.order_by(AuditLog.id.desc())
.offset((page - 1) * page_size)
.limit(page_size)
.all()
)
return {
"items": [_audit_log_out(db, row) for row in rows],
"total": total,