Skip to content

Commit f4153ab

Browse files
committed
Round 4 nits: kill-switch test clarity, sequence cast mask, preferences toast notice
1 parent ea70a71 commit f4153ab

4 files changed

Lines changed: 18 additions & 15 deletions

File tree

application/account/Core/Features/Tenants/Domain/TenantRepository.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,9 @@ public async Task<int> GetNextRolloutIndexUnfilteredAsync(CancellationToken canc
188188
.SingleAsync(cancellationToken);
189189

190190
// Sequence is seeded at COUNT(*)+1, so the first nextval after migration equals the previous COUNT+1.
191-
// Subtracting 1 preserves the original count-based contract used by Tenant.Create. Modulo int.MaxValue
192-
// keeps the cast from overflowing to a negative value past 2.1B cumulative inserts (including
193-
// failed/rolled-back inserts that leak sequence values).
194-
return (int)((nextSequenceValue - 1) % int.MaxValue);
191+
// Subtracting 1 preserves the original count-based contract used by Tenant.Create. The mask keeps
192+
// the cast non-negative past 2.1B cumulative inserts (including rolled-back/leaked values) while
193+
// preserving int.MaxValue itself (the `% int.MaxValue` form silently collapses that value to 0).
194+
return (int)((nextSequenceValue - 1) & 0x7FFF_FFFF);
195195
}
196196
}

application/account/Core/Features/Users/Domain/UserRepository.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -580,10 +580,10 @@ public async Task<int> GetNextRolloutIndexUnfilteredAsync(CancellationToken canc
580580
.SingleAsync(cancellationToken);
581581

582582
// Sequence is seeded at COUNT(*)+1, so the first nextval after migration equals the previous COUNT+1.
583-
// Subtracting 1 preserves the original count-based contract used by User.Create. Modulo int.MaxValue
584-
// keeps the cast from overflowing to a negative value past 2.1B cumulative inserts (including
585-
// failed/rolled-back inserts that leak sequence values).
586-
return (int)((nextSequenceValue - 1) % int.MaxValue);
583+
// Subtracting 1 preserves the original count-based contract used by User.Create. The mask keeps
584+
// the cast non-negative past 2.1B cumulative inserts (including rolled-back/leaked values) while
585+
// preserving int.MaxValue itself (the `% int.MaxValue` form silently collapses that value to 0).
586+
return (int)((nextSequenceValue - 1) & 0x7FFF_FFFF);
587587
}
588588

589589
/// <summary>

application/account/Tests/FeatureFlags/FeatureFlagEvaluatorTests.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,19 @@ public async Task Evaluate_WhenBaseRowInactive_ShouldReturnEmpty()
6363
[Fact]
6464
public async Task Evaluate_WhenManualOverrideEnabledAndBaseRowInactive_ShouldExcludeFlag()
6565
{
66-
// Arrange — base row is inactive (admin Deactivate); tenant has an active manual override.
67-
// Per the documented precedence chain, an inactive base row is the global kill switch and
68-
// short-circuits before the manual-override step is reached.
66+
// Arrange — beta-features is a kill-switch flag and the base row is left inactive (the panic
67+
// button is pulled). The tenant has an active manual override. Per the documented precedence
68+
// chain, an inactive base row short-circuits before the manual-override step is reached so
69+
// pulling the kill switch is truly global, even for tenants admins had explicitly opted in.
6970
var now = TimeProvider.System.GetUtcNow();
70-
InsertFeatureFlag("sso", null, null, null, null, null, null);
71-
InsertFeatureFlag("sso", DatabaseSeeder.Tenant1.Id.Value, null, now, null, null, null);
71+
InsertFeatureFlag("beta-features", null, null, null, null, null, null);
72+
InsertFeatureFlag("beta-features", DatabaseSeeder.Tenant1.Id.Value, null, now, null, null, null);
7273

7374
// Act
7475
var result = await _evaluationService.EvaluateAsync(DatabaseSeeder.Tenant1.Id, DatabaseSeeder.Tenant1Owner.Id, 50, 50, null, null, CancellationToken.None);
7576

7677
// Assert
77-
result.Should().NotContain("sso");
78+
result.Should().NotContain("beta-features");
7879
}
7980

8081
[Fact]

application/account/WebApp/routes/user/preferences/-components/PreferencesFeatureFlagsSection.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ function UserFlagToggle({ flagKey, enabled }: Readonly<UserFlag>) {
4444

4545
const toggleMutation = api.useMutation("put", "/api/account/feature-flags/{flagKey}/user-override", {
4646
onSuccess: () => {
47-
toast.success(t`Preference updated successfully`, { description: label.name });
47+
toast.success(t`Preference updated successfully`, {
48+
description: `${label.name}. ${t`It takes up to 5 minutes for changes to reach all users.`}`
49+
});
4850
}
4951
});
5052

0 commit comments

Comments
 (0)