Skip to content

Commit 8027a1e

Browse files
svenefftingeroboquat
authored andcommitted
[usage] don't reset usage limit
1 parent 4a4d66d commit 8027a1e

File tree

1 file changed

+1
-17
lines changed

1 file changed

+1
-17
lines changed

components/gitpod-db/go/cost_center.go

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -267,22 +267,6 @@ func (c *CostCenterManager) ResetUsage(ctx context.Context, cc CostCenter) (Cost
267267
return CostCenter{}, fmt.Errorf("cannot reset usage for Billing Strategy %s for Cost Center ID: %s", cc.BillingStrategy, cc.ID)
268268
}
269269

270-
entity, _ := cc.ID.Values()
271-
272-
// We do not carry over the spending limit from the existing CostCenter.
273-
// At the moment, we don't have a use case for it. Getting the spending limit from configured values
274-
// ensures that we progressively update the spending limit to configured values rather than having to
275-
// perform bulk DB queries when the defaults do change.
276-
var spendingLimit int32
277-
switch entity {
278-
case AttributionEntity_Team:
279-
spendingLimit = c.cfg.ForTeams
280-
case AttributionEntity_User:
281-
spendingLimit = c.cfg.ForUsers
282-
default:
283-
return CostCenter{}, fmt.Errorf("cannot reset usage for unknown attribution entity ID: %s", cc.ID)
284-
}
285-
286270
now := time.Now().UTC()
287271

288272
// Default to 1 month from now, if there's no nextBillingTime set on the record.
@@ -300,7 +284,7 @@ func (c *CostCenterManager) ResetUsage(ctx context.Context, cc CostCenter) (Cost
300284
// All fields on the new cost center remain the same, except for BillingCycleStart, NextBillingTime, and CreationTime
301285
newCostCenter := CostCenter{
302286
ID: cc.ID,
303-
SpendingLimit: spendingLimit,
287+
SpendingLimit: cc.SpendingLimit,
304288
BillingStrategy: cc.BillingStrategy,
305289
BillingCycleStart: NewVarCharTime(now),
306290
NextBillingTime: NewVarCharTime(nextBillingTime),

0 commit comments

Comments
 (0)