Initial commit of Descrybe v2 without local scratch artifacts.
Drop one-shot tmp/axe scripts and agent i18n scratch so the Gitea tree is deployable.
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
package billing
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// IsEphemeralTestPlanName reports integration-test plan rows that should stay
|
||||
// out of the admin "catalog" filter (consume-contention-*, claim-test-plan-*, multi-plan-*).
|
||||
func IsEphemeralTestPlanName(name string) bool {
|
||||
n := strings.ToLower(strings.TrimSpace(name))
|
||||
if n == "" {
|
||||
return false
|
||||
}
|
||||
return strings.HasPrefix(n, "consume-contention-") ||
|
||||
strings.HasPrefix(n, "claim-test-plan-") ||
|
||||
strings.HasPrefix(n, "multi-plan-")
|
||||
}
|
||||
|
||||
// IsObsoleteLadderPlanName reports pre-v2 public ladder leftovers that must never
|
||||
// appear on Choose your plan (Basic / Professional / Merkur / Mini).
|
||||
func IsObsoleteLadderPlanName(name string) bool {
|
||||
switch strings.ToLower(strings.TrimSpace(name)) {
|
||||
case "basic", "professional", "mini", "merkur", "meur", "merkur trial":
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// EnsurePlanCatalogHygiene soft-hides obsolete ladder leftovers and forces EPREL
|
||||
// on for every plan (public EU data — never credit-gated).
|
||||
//
|
||||
// Soft-hide: mark Basic/Professional/… as is_custom with an archived description
|
||||
// so they never look like self-serve product rows. Rows are not deleted (may be
|
||||
// referenced by history). Ephemeral test plans are left in DB but filtered in admin UI.
|
||||
func (s *Service) EnsurePlanCatalogHygiene(ctx context.Context) error {
|
||||
if s == nil || s.Pool == nil {
|
||||
return nil
|
||||
}
|
||||
_, err := s.Pool.Exec(ctx, `
|
||||
UPDATE plans SET
|
||||
is_custom = true,
|
||||
description = CASE
|
||||
WHEN description IS NULL OR btrim(description) = '' THEN
|
||||
'Archived pre-v2 plan (hidden from Choose your plan)'
|
||||
WHEN description LIKE 'Archived pre-v2%' THEN description
|
||||
ELSE 'Archived pre-v2 plan (hidden from Choose your plan). ' || description
|
||||
END,
|
||||
updated_at = now()
|
||||
WHERE lower(name) IN ('basic', 'professional', 'mini', 'merkur', 'meur', 'merkur trial')
|
||||
AND is_custom = false`)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Never leave an explicit capability.eprel=false override — EPREL is free on all plans.
|
||||
_, err = s.Pool.Exec(ctx, `
|
||||
UPDATE plans
|
||||
SET features = features || '{"capability.eprel": true}'::jsonb,
|
||||
updated_at = now()
|
||||
WHERE features ? 'capability.eprel'
|
||||
AND (features->>'capability.eprel') = 'false'`)
|
||||
if err != nil {
|
||||
if isUndefinedColumn(err) {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user