Repository navigation
Conversation
seafile-dev
requested changes
Oct 8, 2026
| org_cost_delta = defaultdict(float) | ||
| for data in team_data: | ||
| org_cost_delta[data['org_id']] += data['cost'] | ||
| self.additional_credits_manager.deduct(org_cost_delta, month) |
There was a problem hiding this comment.
【严重】统计失败仍会扣减余额
影响:
session.execute 或 commit 失败时,异常只被记录,随后仍无条件调用 deduct。本批用量没有写入 stats_ai_by_team,扣减逻辑却会用旧累计用量加上 cost_delta 计算超额,可能扣掉团队余额而没有对应的用量统计。
建议修复:仅在统计写入并成功提交后再构建 org_cost_delta 和调用 deduct;失败路径应跳过本批扣减并保留数据供后续重试。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.