Update app/dataplane/account/feedback.py
Browse files
app/dataplane/account/feedback.py
CHANGED
|
@@ -13,6 +13,9 @@ selector strategy. No runtime ``if`` inside the apply helpers themselves.
|
|
| 13 |
from app.platform.runtime.clock import now_s
|
| 14 |
from ..shared.enums import ALL_MODE_IDS, StatusId
|
| 15 |
from .table import AccountRuntimeTable
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
# Health adjustment constants.
|
| 18 |
_SUCCESS_STEP = 0.12
|
|
@@ -168,6 +171,18 @@ def _adjust_health(table: AccountRuntimeTable, idx: int, factor: float) -> None:
|
|
| 168 |
_MIN_HEALTH, float(table.health_by_idx[idx]) * factor
|
| 169 |
)
|
| 170 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 171 |
|
| 172 |
__all__ = [
|
| 173 |
"apply_success_quota",
|
|
|
|
| 13 |
from app.platform.runtime.clock import now_s
|
| 14 |
from ..shared.enums import ALL_MODE_IDS, StatusId
|
| 15 |
from .table import AccountRuntimeTable
|
| 16 |
+
from app.control.account.runtime import global_auditor
|
| 17 |
+
from app.control.account.models import AuditLogRecord
|
| 18 |
+
|
| 19 |
|
| 20 |
# Health adjustment constants.
|
| 21 |
_SUCCESS_STEP = 0.12
|
|
|
|
| 171 |
_MIN_HEALTH, float(table.health_by_idx[idx]) * factor
|
| 172 |
)
|
| 173 |
|
| 174 |
+
# 在已有的异步反馈函数结束位置(例如 success 或 fail 状态判定后)追加:
|
| 175 |
+
def trigger_audit_log(token: str, quota_type: str, status: str, ctx: dict):
|
| 176 |
+
log_rec = AuditLogRecord(
|
| 177 |
+
token=token,
|
| 178 |
+
device_ip=ctx.get("client_ip", "0.0.0.0"),
|
| 179 |
+
user_agent=ctx.get("user_agent", "Unknown"),
|
| 180 |
+
conversation_id=ctx.get("conversation_id"),
|
| 181 |
+
quota_type=quota_type, # 通过传入的 mode 映射,比如 'fast' 或 'console'
|
| 182 |
+
status=status # "SUCCESS" 或 "FAIL"
|
| 183 |
+
)
|
| 184 |
+
global_auditor.record(log_rec)
|
| 185 |
+
|
| 186 |
|
| 187 |
__all__ = [
|
| 188 |
"apply_success_quota",
|