Skip to content

Commit

Permalink
FF-2465 make orderPosition 1-indexed to match UI
Browse files Browse the repository at this point in the history
  • Loading branch information
greghuels committed Jun 26, 2024
1 parent b1cf4a8 commit ebed05a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/evaluator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class Evaluator {
unmatchedAllocations.push({
key: allocation.key,
allocationEvaluationCode: code,
orderPosition: i,
orderPosition: i + 1,
});
};

Expand Down
9 changes: 5 additions & 4 deletions src/flag-evaluation-details-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export class FlagEvaluationDetailsBuilder {
};

setMatch = (
orderPosition: number,
indexPosition: number,
variation: Variation,
allocation: Allocation,
matchedRule: Rule | null,
Expand All @@ -103,16 +103,17 @@ export class FlagEvaluationDetailsBuilder {
this.matchedAllocation = {
key: allocation.key,
allocationEvaluationCode: AllocationEvaluationCode.MATCH,
orderPosition,
orderPosition: indexPosition + 1, // orderPosition is 1-indexed to match UI
};
this.unmatchedAllocations = unmatchedAllocations;
const unevaluatedStartIndex = orderPosition + 1;
const unevaluatedStartIndex = indexPosition + 1;
const unevaluatedStartOrderPosition = unevaluatedStartIndex + 1; // orderPosition is 1-indexed to match UI
this.unevaluatedAllocations = this.allocations.slice(unevaluatedStartIndex).map(
(allocation, i) =>
({
key: allocation.key,
allocationEvaluationCode: AllocationEvaluationCode.UNEVALUATED,
orderPosition: unevaluatedStartIndex + i,
orderPosition: unevaluatedStartOrderPosition + i,
} as AllocationEvaluation),
);
return this;
Expand Down

0 comments on commit ebed05a

Please sign in to comment.