MCPcopy Create free account
hub / github.com/ZyphrZero/z.ai2api_python / record_success

Method record_success

app/services/token_dao.py:265–278  ·  view source on GitHub ↗

记录 Token 使用成功

(self, token_id: int)

Source from the content-addressed store, hash-verified

263 # ==================== Token 统计操作 ====================
264
265 async def record_success(self, token_id: int):
266 """记录 Token 使用成功"""
267 try:
268 async with self.get_connection() as conn:
269 await conn.execute("""
270 UPDATE token_stats
271 SET total_requests = total_requests + 1,
272 successful_requests = successful_requests + 1,
273 last_success_time = CURRENT_TIMESTAMP
274 WHERE token_id = ?
275 """, (token_id,))
276 await conn.commit()
277 except Exception as e:
278 logger.error(f"❌ 记录成功失败: {e}")
279
280 async def record_failure(self, token_id: int):
281 """记录 Token 使用失败"""

Callers 2

record_token_successMethod · 0.80
sync_token_stats_to_dbFunction · 0.80

Calls 1

get_connectionMethod · 0.95

Tested by

no test coverage detected