fix(battle-pass): remove redundant SaveChanges after CommitAsync
CommitAsync's inner SaveChangesAsync already flushes the AddClaim rows + progress.IsPremium mutation alongside the inventory grants (same scoped DbContext). The trailing _db.SaveChangesAsync was a no-op in BuyPremium and only meaningful in AddPoints when no level crossed (no tx opened) — restructured to an else branch. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -191,8 +191,9 @@ public sealed class BattlePassService : IBattlePassService
|
||||
// op, any grants override the post-state. result.RewardList carries the final
|
||||
// post-state including the deducted crystal balance. result.Deltas carries the raw
|
||||
// grant amounts for achieved_info (no spend entry in Deltas, only GrantOps).
|
||||
// CommitAsync's SaveChangesAsync flushes the AddClaim rows + the progress.IsPremium
|
||||
// mutation alongside the inventory grants — all tracked on the same scoped DbContext.
|
||||
var result = await tx.CommitAsync(ct);
|
||||
await _db.SaveChangesAsync(ct); // flush claim rows added via _viewerBp.AddClaim
|
||||
|
||||
return new BattlePassBuyOutcome(1, result.Deltas, result.RewardList);
|
||||
}
|
||||
@@ -246,8 +247,12 @@ public sealed class BattlePassService : IBattlePassService
|
||||
var result = await tx.CommitAsync(ct);
|
||||
newlyClaimed = result.Deltas;
|
||||
}
|
||||
|
||||
await _db.SaveChangesAsync(ct);
|
||||
else
|
||||
{
|
||||
// No level crossed → no tx opened → still need to persist the progress mutation
|
||||
// (CurrentPoint/WeeklyPoints/WeeklyPeriodStart) tracked on the scoped DbContext.
|
||||
await _db.SaveChangesAsync(ct);
|
||||
}
|
||||
|
||||
return new BattlePassPointGrant(
|
||||
BeforePoint: beforePoint,
|
||||
|
||||
Reference in New Issue
Block a user