| index 60bcdfe9e..f83ceed4c 100644 |
| --- a/internal/console/plansponsor.go |
| +++ b/internal/console/plansponsor.go |
| @@ -200,7 +200,13 @@ func (s *Store) clearLaunchRuleCarrying(launch plans.Limits, reason, by string, |
| // 2026-11-03) and media_minutes_month (media conversion). A launch row |
| // lacking one gets its plan's figure (Free's 100 PDFs, 30 media minutes) |
| // while every other figure is unlimited. |
| -var launchCarried = []string{"pdf_renders_month", "media_minutes_month"} |
| +var launchCarried = []struct { |
| + key string // the field's JSON name |
| + set func(l *plans.Limits, launch plans.Limits) // copies launch's figure into l |
| +}{ |
| + {"pdf_renders_month", func(l *plans.Limits, launch plans.Limits) { l.PDFRendersMonth = launch.PDFRendersMonth }}, |
| + {"media_minutes_month", func(l *plans.Limits, launch plans.Limits) { l.MediaMinutesMonth = launch.MediaMinutesMonth }}, |
| +} |
| |
| // carryLaunchFiguresTx gives every launch sponsorship that lacks one of |
| // launchCarried the figure launch now carries (Task 6 fix rounds 1 and 2), |
| @@ -227,9 +233,9 @@ func carryLaunchFiguresTx(tx *sql.Tx, launch plans.Limits, reason, by string, no |
| if err != nil { |
| return 0, err |
| } |
| - for _, k := range launchCarried { |
| - if _, ok := want[k]; !ok { |
| - return 0, fmt.Errorf("console: the launch figures have no %s to carry", k) |
| + for _, c := range launchCarried { |
| + if _, ok := want[c.key]; !ok { |
| + return 0, fmt.Errorf("console: the launch figures have no %s to carry", c.key) |
| } |
| } |
| rows, err := tx.Query(`SELECT account_id, sponsored FROM account_plans |
| @@ -261,8 +267,8 @@ func carryLaunchFiguresTx(tx *sql.Tx, launch plans.Limits, reason, by string, no |
| continue // not launch's shape: leave it |
| } |
| missing := false |
| - for _, k := range launchCarried { |
| - _, ok := have[k] |
| + for _, c := range launchCarried { |
| + _, ok := have[c.key] |
| missing = missing || !ok |
| } |
| if !missing { |
| @@ -278,21 +284,19 @@ func carryLaunchFiguresTx(tx *sql.Tx, launch plans.Limits, reason, by string, no |
| if !same { |
| continue |
| } |
| - for _, k := range launchCarried { |
| - if _, ok := have[k]; !ok { |
| - have[k] = want[k] |
| - } |
| - } |
| - // Through plans.Limits, so the stored form is the one |
| - // accountPlanUpsertArgs writes. |
| - mj, err := json.Marshal(have) |
| - if err != nil { |
| - return 0, err |
| - } |
| + // The row's own figures as plans.Limits, the missing ones set |
| + // from launch, so the stored form is the one accountPlanUpsertArgs |
| + // writes. (have only compares: marshalling it would hand the JSON |
| + // guard a decoded map it cannot follow, gate_shadow_guard_test.go.) |
| var l plans.Limits |
| - if err := json.Unmarshal(mj, &l); err != nil { |
| + if err := json.Unmarshal([]byte(r.sponsored), &l); err != nil { |
| continue |
| } |
| + for _, c := range launchCarried { |
| + if _, ok := have[c.key]; !ok { |
| + c.set(&l, launch) |
| + } |
| + } |
| nj, err := json.Marshal(l) |
| if err != nil { |
| return 0, err |