@stackedapp/utils 1.23.5 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -48,9 +48,14 @@ const calculateDynamicGroupPercent = (dynamicObj, group) => {
|
|
|
48
48
|
if (!group?.conditions?.length)
|
|
49
49
|
return 100;
|
|
50
50
|
const percentages = group.conditions.map((c) => (0, exports.calculateDynamicConditionPercent)(dynamicObj, c));
|
|
51
|
-
if (!group.links?.length) {
|
|
51
|
+
if (!group.links?.length || group.links.every((l) => l === 'AND')) {
|
|
52
52
|
return percentages.reduce((sum, p) => sum + p, 0) / percentages.length;
|
|
53
53
|
}
|
|
54
|
+
if (group.links.every((l) => l === 'AND NOT')) {
|
|
55
|
+
const adjusted = [percentages[0], ...percentages.slice(1).map((p) => 100 - p)];
|
|
56
|
+
return adjusted.reduce((sum, p) => sum + p, 0) / adjusted.length;
|
|
57
|
+
}
|
|
58
|
+
// Mixed links: fall back to pairwise evaluation
|
|
54
59
|
let result = percentages[0];
|
|
55
60
|
for (let i = 0; i < group.links.length; i++) {
|
|
56
61
|
const nextPct = percentages[i + 1];
|