@meith/groups 0.21.2 → 0.22.0
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.
- package/package.json +1 -1
- package/src/promotion.ts +5 -3
package/package.json
CHANGED
package/src/promotion.ts
CHANGED
|
@@ -62,8 +62,8 @@ export function evaluatePromotions(
|
|
|
62
62
|
now: Date = new Date(),
|
|
63
63
|
): PromotionOutcome[] {
|
|
64
64
|
const protectedIds = new Set(guards.protectedGroupIds)
|
|
65
|
-
const rankOf = (groupId: number | null): number =>
|
|
66
|
-
groupId === null ?
|
|
65
|
+
const rankOf = (groupId: number | null): number | undefined =>
|
|
66
|
+
groupId === null ? undefined : guards.rank?.get(groupId)
|
|
67
67
|
|
|
68
68
|
const active = [...rules]
|
|
69
69
|
.filter((r) => r.enabled)
|
|
@@ -79,7 +79,9 @@ export function evaluatePromotions(
|
|
|
79
79
|
|
|
80
80
|
if (user.primaryGroupId === rule.toPrimaryGroupId) break
|
|
81
81
|
|
|
82
|
-
|
|
82
|
+
const to = rankOf(rule.toPrimaryGroupId)
|
|
83
|
+
const from = rankOf(user.primaryGroupId)
|
|
84
|
+
if (to !== undefined && from !== undefined && to < from) break
|
|
83
85
|
|
|
84
86
|
outcomes.push({
|
|
85
87
|
userId: user.userId,
|