Skip to content

Commit ce2ec30

Browse files
committed
fix: flagfs
1 parent 6e2c00d commit ce2ec30

File tree

9 files changed

+413
-448
lines changed

9 files changed

+413
-448
lines changed

apps/api/src/routes/public/flags.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ interface UserContext {
1313
}
1414

1515
interface FlagRule {
16-
type: 'user_id' | 'email' | 'property' | 'percentage';
16+
type: 'user_id' | 'email' | 'property';
1717
operator: string;
1818
field?: string;
1919
value?: unknown;
@@ -311,7 +311,7 @@ describe('Flag Evaluation System', () => {
311311
describe('Percentage Rules', () => {
312312
it('should enable users within percentage threshold', () => {
313313
const rule: FlagRule = {
314-
type: 'percentage',
314+
type: 'property',
315315
operator: 'equals',
316316
value: 50,
317317
enabled: true,
@@ -335,7 +335,7 @@ describe('Flag Evaluation System', () => {
335335

336336
it('should be consistent for same user', () => {
337337
const rule: FlagRule = {
338-
type: 'percentage',
338+
type: 'property',
339339
operator: 'equals',
340340
value: 25,
341341
enabled: true,
@@ -354,7 +354,7 @@ describe('Flag Evaluation System', () => {
354354

355355
it('should handle invalid percentage values', () => {
356356
const rule: FlagRule = {
357-
type: 'percentage',
357+
type: 'property',
358358
operator: 'equals',
359359
value: 'invalid',
360360
enabled: true,
@@ -694,7 +694,7 @@ describe('Flag Evaluation System', () => {
694694
payload: { rollout: true },
695695
rules: [
696696
{
697-
type: 'percentage',
697+
type: 'property',
698698
operator: 'equals',
699699
value: 30,
700700
enabled: false,
@@ -785,7 +785,7 @@ describe('Flag Evaluation System', () => {
785785
payload: { percentage: true },
786786
rules: [
787787
{
788-
type: 'percentage',
788+
type: 'property',
789789
operator: 'equals',
790790
value: 25,
791791
enabled: true,

apps/api/src/routes/public/flags.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ interface UserContext {
2525
}
2626

2727
interface FlagRule {
28-
type: 'user_id' | 'email' | 'property' | 'percentage';
28+
type: 'user_id' | 'email' | 'property';
2929
operator: string;
3030
field?: string;
3131
value?: unknown;
@@ -155,15 +155,15 @@ export function evaluateRule(rule: FlagRule, context: UserContext): boolean {
155155
const propertyValue = context.properties?.[rule.field];
156156
return evaluateValueRule(propertyValue, rule);
157157
}
158-
case 'percentage': {
159-
if (typeof rule.value !== 'number') {
160-
return false;
161-
}
162-
const userId = context.userId || context.email || 'anonymous';
163-
const hash = hashString(`percentage:${userId}`);
164-
const percentage = hash % 100;
165-
return percentage < rule.value;
166-
}
158+
// case 'percentage': {
159+
// if (typeof rule.value !== 'number') {
160+
// return false;
161+
// }
162+
// const userId = context.userId || context.email || 'anonymous';
163+
// const hash = hashString(`percentage:${userId}`);
164+
// const percentage = hash % 100;
165+
// return percentage < rule.value;
166+
// }
167167
default:
168168
return false;
169169
}

0 commit comments

Comments
 (0)