@naturalcycles/abba 1.17.0 → 1.17.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 +6 -2
- package/package.json +1 -1
- package/src/abba.ts +6 -4
package/dist/abba.js
CHANGED
|
@@ -110,10 +110,13 @@ class Abba {
|
|
|
110
110
|
* @param segmentationData Required if existingOnly is false
|
|
111
111
|
*/
|
|
112
112
|
async getUserAssignment(experimentKey, userId, existingOnly, segmentationData) {
|
|
113
|
-
const existingAssignments = await this.getAllExistingUserAssignments(userId);
|
|
114
113
|
const experiment = await this.experimentDao.getOneBy('key', experimentKey);
|
|
115
114
|
(0, js_lib_1._assert)(experiment, `Experiment does not exist: ${experimentKey}`);
|
|
115
|
+
// Inactive experiments should never return an assignment
|
|
116
|
+
if (experiment.status === types_1.AssignmentStatus.Inactive)
|
|
117
|
+
return null;
|
|
116
118
|
const buckets = await this.bucketDao.getBy('experimentId', experiment.id);
|
|
119
|
+
const existingAssignments = await this.getAllExistingUserAssignments(userId);
|
|
117
120
|
const existing = existingAssignments.find(a => a.experimentId === experiment.id);
|
|
118
121
|
if (existing) {
|
|
119
122
|
return {
|
|
@@ -122,7 +125,8 @@ class Abba {
|
|
|
122
125
|
bucketKey: buckets.find(b => b.id === existing.bucketId)?.key || null,
|
|
123
126
|
};
|
|
124
127
|
}
|
|
125
|
-
|
|
128
|
+
// No existing assignment, but we don't want to generate a new one
|
|
129
|
+
if (existingOnly || experiment.status === types_1.AssignmentStatus.Paused)
|
|
126
130
|
return null;
|
|
127
131
|
const experiments = await this.getAllExperiments();
|
|
128
132
|
const exclusionSet = (0, util_1.getUserExclusionSet)(experiments, existingAssignments);
|
package/package.json
CHANGED
package/src/abba.ts
CHANGED
|
@@ -157,13 +157,14 @@ export class Abba {
|
|
|
157
157
|
existingOnly: boolean,
|
|
158
158
|
segmentationData?: SegmentationData,
|
|
159
159
|
): Promise<GeneratedUserAssignment | null> {
|
|
160
|
-
const existingAssignments = await this.getAllExistingUserAssignments(userId)
|
|
161
|
-
|
|
162
160
|
const experiment = await this.experimentDao.getOneBy('key', experimentKey)
|
|
163
161
|
_assert(experiment, `Experiment does not exist: ${experimentKey}`)
|
|
164
162
|
|
|
165
|
-
|
|
163
|
+
// Inactive experiments should never return an assignment
|
|
164
|
+
if (experiment.status === AssignmentStatus.Inactive) return null
|
|
166
165
|
|
|
166
|
+
const buckets = await this.bucketDao.getBy('experimentId', experiment.id)
|
|
167
|
+
const existingAssignments = await this.getAllExistingUserAssignments(userId)
|
|
167
168
|
const existing = existingAssignments.find(a => a.experimentId === experiment.id)
|
|
168
169
|
if (existing) {
|
|
169
170
|
return {
|
|
@@ -173,7 +174,8 @@ export class Abba {
|
|
|
173
174
|
}
|
|
174
175
|
}
|
|
175
176
|
|
|
176
|
-
|
|
177
|
+
// No existing assignment, but we don't want to generate a new one
|
|
178
|
+
if (existingOnly || experiment.status === AssignmentStatus.Paused) return null
|
|
177
179
|
|
|
178
180
|
const experiments = await this.getAllExperiments()
|
|
179
181
|
const exclusionSet = getUserExclusionSet(experiments, existingAssignments)
|