@naturalcycles/abba 1.14.1 → 1.15.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.
- package/dist/abba.js +2 -2
- package/dist/dao/experiment.dao.js +0 -1
- package/dist/util.js +4 -0
- package/package.json +1 -1
- package/src/abba.ts +2 -2
- package/src/dao/experiment.dao.ts +1 -2
- package/src/util.ts +4 -0
package/dist/abba.js
CHANGED
|
@@ -62,7 +62,7 @@ class Abba {
|
|
|
62
62
|
if (experiment.status === types_1.AssignmentStatus.Active) {
|
|
63
63
|
(0, util_1.validateTotalBucketRatio)(buckets);
|
|
64
64
|
}
|
|
65
|
-
const updatedExperiment = await this.experimentDao.save(experiment);
|
|
65
|
+
const updatedExperiment = await this.experimentDao.save(experiment, { saveMethod: 'update' });
|
|
66
66
|
const updatedBuckets = await this.bucketDao.saveBatch(buckets.map(b => ({ ...b, experimentId: experiment.id })));
|
|
67
67
|
await this.updateExclusions(updatedExperiment.id, updatedExperiment.exclusions);
|
|
68
68
|
return {
|
|
@@ -90,7 +90,7 @@ class Abba {
|
|
|
90
90
|
requiresUpdating.push(experiment);
|
|
91
91
|
}
|
|
92
92
|
});
|
|
93
|
-
await this.experimentDao.saveBatch(requiresUpdating);
|
|
93
|
+
await this.experimentDao.saveBatch(requiresUpdating, { saveMethod: 'update' });
|
|
94
94
|
}
|
|
95
95
|
/**
|
|
96
96
|
* Delete an experiment. Removes all user assignments and buckets.
|
package/dist/util.js
CHANGED
|
@@ -126,6 +126,10 @@ exports.canGenerateNewAssignments = canGenerateNewAssignments;
|
|
|
126
126
|
const getUserExclusionSet = (experiments, existingAssignments) => {
|
|
127
127
|
const exclusionSet = new Set();
|
|
128
128
|
existingAssignments.forEach(assignment => {
|
|
129
|
+
// Users who are excluded from an experiment due to sampling
|
|
130
|
+
// should not prevent potential assignment to other mutually exclusive experiments
|
|
131
|
+
if (assignment.bucketId === null)
|
|
132
|
+
return;
|
|
129
133
|
const experiment = experiments.find(e => e.id === assignment.experimentId);
|
|
130
134
|
experiment?.exclusions.forEach(experimentId => exclusionSet.add(experimentId));
|
|
131
135
|
});
|
package/package.json
CHANGED
package/src/abba.ts
CHANGED
|
@@ -92,7 +92,7 @@ export class Abba {
|
|
|
92
92
|
validateTotalBucketRatio(buckets)
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
const updatedExperiment = await this.experimentDao.save(experiment)
|
|
95
|
+
const updatedExperiment = await this.experimentDao.save(experiment, { saveMethod: 'update' })
|
|
96
96
|
const updatedBuckets = await this.bucketDao.saveBatch(
|
|
97
97
|
buckets.map(b => ({ ...b, experimentId: experiment.id })),
|
|
98
98
|
)
|
|
@@ -132,7 +132,7 @@ export class Abba {
|
|
|
132
132
|
}
|
|
133
133
|
})
|
|
134
134
|
|
|
135
|
-
await this.experimentDao.saveBatch(requiresUpdating)
|
|
135
|
+
await this.experimentDao.saveBatch(requiresUpdating, { saveMethod: 'update' })
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
/**
|
|
@@ -13,9 +13,8 @@ export const experimentDao = (db: CommonDB): ExperimentDao =>
|
|
|
13
13
|
new ExperimentDao({
|
|
14
14
|
db,
|
|
15
15
|
table: 'Experiment',
|
|
16
|
-
createId: false, //
|
|
16
|
+
createId: false, // Always provided on create
|
|
17
17
|
idType: 'number',
|
|
18
|
-
assignGeneratedIds: true,
|
|
19
18
|
hooks: {
|
|
20
19
|
beforeBMToDBM: bm => ({
|
|
21
20
|
...bm,
|
package/src/util.ts
CHANGED
|
@@ -150,6 +150,10 @@ export const getUserExclusionSet = (
|
|
|
150
150
|
): ExclusionSet => {
|
|
151
151
|
const exclusionSet: ExclusionSet = new Set()
|
|
152
152
|
existingAssignments.forEach(assignment => {
|
|
153
|
+
// Users who are excluded from an experiment due to sampling
|
|
154
|
+
// should not prevent potential assignment to other mutually exclusive experiments
|
|
155
|
+
if (assignment.bucketId === null) return
|
|
156
|
+
|
|
153
157
|
const experiment = experiments.find(e => e.id === assignment.experimentId)
|
|
154
158
|
experiment?.exclusions.forEach(experimentId => exclusionSet.add(experimentId))
|
|
155
159
|
})
|