Skip to content

Commit fada384

Browse files
Polishing
1 parent aee2631 commit fada384

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

src/storages/AbstractSplitsCacheSync.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ export abstract class AbstractSplitsCacheSync implements ISplitsCacheSync {
8080
* Given a parsed split, it returns a boolean flagging if its conditions use segments matchers (rules & whitelists).
8181
* This util is intended to simplify the implementation of `splitsCache::usesSegments` method
8282
*/
83-
export function usesSegments(split: ISplit | IRBSegment) {
84-
const conditions = split.conditions || [];
83+
export function usesSegments(ruleEntity: ISplit | IRBSegment) {
84+
const conditions = ruleEntity.conditions || [];
8585
for (let i = 0; i < conditions.length; i++) {
8686
const matchers = conditions[i].matcherGroup.matchers;
8787

@@ -91,5 +91,8 @@ export function usesSegments(split: ISplit | IRBSegment) {
9191
}
9292
}
9393

94+
const excluded = (ruleEntity as IRBSegment).excluded;
95+
if (excluded && excluded.segments && excluded.segments.length > 0) return true;
96+
9497
return false;
9598
}

src/storages/inLocalStorage/RBSegmentsCacheInLocal.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class RBSegmentsCacheInLocal implements IRBSegmentsCacheSync {
3838
}
3939
}
4040

41-
private updateSegmentCount(diff: number){
41+
private updateSegmentCount(diff: number) {
4242
const segmentsCountKey = this.keys.buildSplitsWithSegmentCountKey();
4343
const count = toNumber(localStorage.getItem(segmentsCountKey)) + diff;
4444
// @ts-expect-error
@@ -128,11 +128,9 @@ export class RBSegmentsCacheInLocal implements IRBSegmentsCacheSync {
128128
const storedCount = localStorage.getItem(this.keys.buildSplitsWithSegmentCountKey());
129129
const splitsWithSegmentsCount = storedCount === null ? 0 : toNumber(storedCount);
130130

131-
if (isFiniteNumber(splitsWithSegmentsCount)) {
132-
return splitsWithSegmentsCount > 0;
133-
} else {
134-
return true;
135-
}
131+
return isFiniteNumber(splitsWithSegmentsCount) ?
132+
splitsWithSegmentsCount > 0 :
133+
true;
136134
}
137135

138136
}

src/storages/inLocalStorage/SplitsCacheInLocal.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,9 @@ export class SplitsCacheInLocal extends AbstractSplitsCacheSync {
206206
const storedCount = localStorage.getItem(this.keys.buildSplitsWithSegmentCountKey());
207207
const splitsWithSegmentsCount = storedCount === null ? 0 : toNumber(storedCount);
208208

209-
if (isFiniteNumber(splitsWithSegmentsCount)) {
210-
return splitsWithSegmentsCount > 0;
211-
} else {
212-
return true;
213-
}
209+
return isFiniteNumber(splitsWithSegmentsCount) ?
210+
splitsWithSegmentsCount > 0 :
211+
true;
214212
}
215213

216214
/**

0 commit comments

Comments
 (0)