执行 Ruff 安全自动修复
This commit is contained in:
@@ -1,17 +1,16 @@
|
||||
"""虎牙任务执行器:积分与商城(由 huya_runner.py 按功能域拆分)。"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import time
|
||||
from datetime import datetime, timezone
|
||||
from typing import Any, TYPE_CHECKING
|
||||
from datetime import UTC, datetime
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from core.huya import HuyaHttpClient
|
||||
from ..models import HuyaAccount, HuyaGoodsSnapshot, HuyaTask
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .huya_runner import HuyaBatchRunner
|
||||
from ..models import HuyaAccount, HuyaGoodsSnapshot, HuyaTask
|
||||
|
||||
|
||||
class GoodsMixin:
|
||||
@@ -83,7 +82,7 @@ class GoodsMixin:
|
||||
points = response.available_score
|
||||
account.points = points
|
||||
account.status = "points_queried"
|
||||
account.updated_at = datetime.now(timezone.utc)
|
||||
account.updated_at = datetime.now(UTC)
|
||||
self._mark_task(worker_db, task, "success", f"积分: {points}", result)
|
||||
|
||||
def _execute_query_exchange_records(
|
||||
@@ -144,7 +143,7 @@ class GoodsMixin:
|
||||
item["score_text"] = f"{int(item.get('score') or 0)}积分"
|
||||
|
||||
account.status = "exchange_records_queried"
|
||||
account.updated_at = datetime.now(timezone.utc)
|
||||
account.updated_at = datetime.now(UTC)
|
||||
count = len(records)
|
||||
message = f"兑换记录 {count} 条" if count else "暂无兑换记录"
|
||||
self._mark_task(worker_db, task, "success", message, result)
|
||||
@@ -202,7 +201,7 @@ class GoodsMixin:
|
||||
for item in result.get("goods", [])
|
||||
if item.get("product_id") and item.get("name")
|
||||
]
|
||||
now = datetime.now(timezone.utc)
|
||||
now = datetime.now(UTC)
|
||||
worker_db.query(HuyaGoodsSnapshot).delete(synchronize_session=False)
|
||||
for item in goods:
|
||||
worker_db.add(
|
||||
@@ -290,7 +289,7 @@ class GoodsMixin:
|
||||
"product_id": str(product_id),
|
||||
"product_name": product_name,
|
||||
"scheduled_at": scheduled_at.isoformat() if scheduled_at else "",
|
||||
"executed_at": datetime.now(timezone.utc).isoformat(),
|
||||
"executed_at": datetime.now(UTC).isoformat(),
|
||||
"goods": snapshot.raw if snapshot else None,
|
||||
}
|
||||
)
|
||||
@@ -305,6 +304,6 @@ class GoodsMixin:
|
||||
return
|
||||
|
||||
account.status = "goods_exchanged"
|
||||
account.updated_at = datetime.now(timezone.utc)
|
||||
account.updated_at = datetime.now(UTC)
|
||||
message = response.msg or f"兑换成功: {product_name}"
|
||||
self._mark_task(worker_db, task, "success", message, result)
|
||||
|
||||
Reference in New Issue
Block a user