mirror of
https://github.com/tiennm99/DocsGPT.git
synced 2026-10-19 08:14:40 +00:00
fix(quotas): address review: resume claims, agent bucket rule, UI races
- A tool continuation refused for usage now releases the resume claim it took; before, retries got a 409 until the stale claim was reverted. - Agent traffic is any row with an agent key or an agent id, so keyless agents and workflow nodes count toward the agent bucket, not direct. - The user quota modal discards responses for a previously opened user. - The usage meter shows every limited bucket, not only 'all'. - Restore the class separator on the analytics stat card that a formatter run removed, and align the OpenRouter DeepSeek description with its rates.
This commit is contained in:
1 parent
69f55b74cb
commit
4bd259fc09
20 files changed
+202
-45
No files matched your search
@@ -144,16 +144,17 @@ class TokenUsageRepository:
|
||||
Args:
|
||||
user_id: The billable user (auth ``sub``).
|
||||
start: Inclusive window start.
|
||||
bucket: ``all``, ``direct`` (rows without an agent key) or
|
||||
``agent`` (rows with one).
|
||||
bucket: ``all``, ``agent`` (rows carrying an agent key or an agent
|
||||
id) or ``direct`` (rows with neither).
|
||||
|
||||
Rollup rows are excluded; side-channel calls count, they are real spend.
|
||||
"""
|
||||
clauses = ["user_id = :user_id", "timestamp >= :start", "source <> ALL(:rollup_sources)"]
|
||||
# Keyless agents and workflow nodes carry an agent id without a key.
|
||||
if bucket == "direct":
|
||||
clauses.append("api_key IS NULL")
|
||||
clauses.append("api_key IS NULL AND agent_id IS NULL")
|
||||
elif bucket == "agent":
|
||||
clauses.append("api_key IS NOT NULL")
|
||||
clauses.append("(api_key IS NOT NULL OR agent_id IS NOT NULL)")
|
||||
elif bucket != "all":
|
||||
raise ValueError(f"unknown usage bucket: {bucket!r}")
|
||||
row = self._conn.execute(
|
||||
|
||||
Reference in new issue
Block a user