From 398b3c1f0d6ade9d27699b0e73dc24fc83ccc07c Mon Sep 17 00:00:00 2001 From: Sabe Jones Date: Thu, 25 Jun 2020 15:06:06 -0500 Subject: [PATCH] fix(ABtest): important parens --- test/common/fns/randomDrop.test.js | 1 + website/common/script/fns/randomDrop.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/test/common/fns/randomDrop.test.js b/test/common/fns/randomDrop.test.js index 4752fa0cca..3ce03286b1 100644 --- a/test/common/fns/randomDrop.test.js +++ b/test/common/fns/randomDrop.test.js @@ -17,6 +17,7 @@ describe('common.fns.randomDrop', () => { user._tmp = user._tmp ? user._tmp : {}; user.items.eggs.Wolf = 0; user.items.food.Meat = 0; + user._id = `a${user._id.slice(1)}`; task = generateTodo({ userId: user._id }); predictableRandom = sandbox.stub().returns(0.5); }); diff --git a/website/common/script/fns/randomDrop.js b/website/common/script/fns/randomDrop.js index ef47ba4380..b4e418ad07 100644 --- a/website/common/script/fns/randomDrop.js +++ b/website/common/script/fns/randomDrop.js @@ -47,7 +47,7 @@ export default function randomDrop (user, options, req = {}, analytics) { let chance = min([Math.abs(task.value - 21.27), 37.5]) / 150 + 0.02; chance *= task.priority // Task priority: +50% for Medium, +100% for Hard // A/B test experiment: start users with +75% drops, diminishing by 5% per level gained - * '12345678'.indexOf(user._id.slice(0, 1)) !== -1 ? (1 + Math.max(0, 80 - (5 * user.stats.lvl)) / 100) : 1 + * ('12345678'.indexOf(user._id.slice(0, 1)) !== -1 ? (1 + Math.max(0, 80 - (5 * user.stats.lvl)) / 100) : 1) * (1 + (task.streak / 100 || 0)) // Streak bonus: +1% per streak * (1 + statsComputed(user).per / 100) // PERception: +1% per point * (1 + (user.contributor.level / 40 || 0)) // Contrib levels: +2.5% per level