Skip to content

Commit

Permalink
Revert "[SUP-48] support 7 day retention for sessions / errors" (#8797)
Browse files Browse the repository at this point in the history
Reverts #8769
  • Loading branch information
mayberryzane committed Jun 18, 2024
1 parent 8f8db36 commit da7d661
Show file tree
Hide file tree
Showing 28 changed files with 515 additions and 554 deletions.
1 change: 0 additions & 1 deletion backend/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,6 @@ type Project struct {
// Manual monthly session limit override
MonthlySessionLimit *int
WorkspaceID int
Workspace *Workspace
FreeTier bool `gorm:"default:false"`
ExcludedUsers pq.StringArray `json:"excluded_users" gorm:"type:text[]"`
ErrorFilters pq.StringArray `gorm:"type:text[]"`
Expand Down
25 changes: 15 additions & 10 deletions backend/pricing/pricing.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,8 +545,6 @@ func ProductToBasePriceCents(productType model.PricingProductType, planType back

func RetentionMultiplier(retentionPeriod backend.RetentionPeriod) float64 {
switch retentionPeriod {
case backend.RetentionPeriodSevenDays:
return 1
case backend.RetentionPeriodThirtyDays:
return 1
case backend.RetentionPeriodThreeMonths:
Expand Down Expand Up @@ -733,6 +731,19 @@ func GetStripePrices(stripeClient *client.API, workspace *model.Workspace, produ
priceListParams.LookupKeys = []*string{&baseLookupKey, &sessionsLookupKey, &membersLookupKey, &errorsLookupKey, &logsLookupKey, &tracesLookupKey}
prices := stripeClient.Prices.List(&priceListParams).PriceList().Data

// Validate that we received exactly 1 response for each lookup key
expected := len(priceListParams.LookupKeys)
actual := len(prices)
if expected != actual {
searchedKeys := lo.Map(priceListParams.LookupKeys, func(key *string, _ int) string {
return *key
})
foundKeys := lo.Map(prices, func(price *stripe.Price, _ int) string {
return price.LookupKey
})
return nil, e.Errorf("expected %d prices, received %d; searched %#v, found %#v", expected, actual, searchedKeys, foundKeys)
}

priceMap := map[model.PricingProductType]*stripe.Price{}
for _, price := range prices {
switch price.LookupKey {
Expand Down Expand Up @@ -767,14 +778,8 @@ func GetStripePrices(stripeClient *client.API, workspace *model.Workspace, produ
}
}

expected := len(priceListParams.LookupKeys)
actual := len(priceMap)
if actual != expected {
searchedKeys := lo.Map(priceListParams.LookupKeys, func(key *string, _ int) string {
return *key
})
foundProducts := lo.Keys(priceMap)
return nil, e.Errorf("expected %d prices, received %d; searched %#v, found %#v", expected, actual, searchedKeys, foundProducts)
if len(priceMap) != expected {
return nil, e.New("one or more prices was not found")
}

return priceMap, nil
Expand Down
Loading

0 comments on commit da7d661

Please sign in to comment.