fix: default to 100 when attribute weight undefined (#18145)

Co-authored-by: CarinaWolli <wollencarina@gmail.com>
This commit is contained in:
Carina Wollendorfer
2024-12-12 22:57:43 +00:00
committed by GitHub
co-authored by CarinaWolli
parent 6463983d55
commit 8d0f0d4899
+6 -5
View File
@@ -868,15 +868,15 @@ function getAverageAttributeWeights<
);
allRRHosts.forEach((rrHost) => {
const weight = attributeOptionWithUsers?.assignedUsers.find(
const assignedUser = attributeOptionWithUsers?.assignedUsers.find(
(assignedUser) => rrHost.user.id === assignedUser.member.userId
)?.weight;
);
if (weight) {
if (assignedUser) {
if (allRRHostsWeights.has(rrHost.user.id)) {
allRRHostsWeights.get(rrHost.user.id)?.push(weight);
allRRHostsWeights.get(rrHost.user.id)?.push(assignedUser.weight ?? 100);
} else {
allRRHostsWeights.set(rrHost.user.id, [weight]);
allRRHostsWeights.set(rrHost.user.id, [assignedUser.weight ?? 100]);
}
}
});
@@ -897,6 +897,7 @@ function getAverageAttributeWeights<
"getAverageAttributeWeights",
safeStringify({ allRRHosts, attributesQueryValueChild, attributeWithWeights, averageWeightsHosts })
);
return averageWeightsHosts;
}