fix: report combined member limit in group AI spend (#27589)

## Problem

The organization groups page showed each group's AI budget as the
group's per-member limit, so the total it displayed was effectively
group members × group budget. That ignores per-user budget overrides
charged to the group, so a group where one member has an override
reported a limit that doesn't match what its members can actually spend.

## Changes

- Add `total_spend_limit_micros` to the organization groups AI spend
payload, the combined budget of the members attributed to the group,
with each member's override replacing their share.
- Return `null` for the total when the group has no budget, since its
members spend without a cap.
- Both the organization groups and single group spend endpoints report
the new field, as they share the same query.
- Use the total as the denominator on the groups page AI budget column.

Depends on #27568
This commit is contained in:
Susana Ferreira
2026-07-29 09:16:37 +01:00
committed by GitHub
parent e96d8646e2
commit 0b4095085e
14 changed files with 705 additions and 177 deletions
+8 -4
View File
@@ -84,11 +84,15 @@ type OrganizationGroupsAISpend struct {
// within the active budget period.
type OrganizationGroupAISpend struct {
GroupID uuid.UUID `json:"group_id" format:"uuid"`
// SpendLimitMicros is the group's configured AI spend limit. Null when
// the group has no configured budget.
// SpendLimitMicros is the group's configured AI spend budget per member.
// Null when the group has no configured budget.
SpendLimitMicros *int64 `json:"spend_limit_micros"`
// CurrentSpendMicros is the group's spend over the current budget
// period.
// TotalSpendLimitMicros is the currently configured combined budget of the
// members attributed to this group, with each member's override replacing
// their share. Null when the group has no budget, and zero when no members
// are attributed to it.
TotalSpendLimitMicros *int64 `json:"total_spend_limit_micros"`
// CurrentSpendMicros is the group's spend over the current budget period.
CurrentSpendMicros int64 `json:"current_spend_micros"`
}