@naturalcycles/abba 1.10.0 → 1.11.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/dist/abba.js +6 -9
- package/dist/migrations/init.sql +0 -1
- package/dist/types.d.ts +1 -2
- package/package.json +1 -1
- package/src/abba.ts +6 -9
- package/src/migrations/init.sql +0 -1
- package/src/types.ts +1 -2
package/dist/abba.js
CHANGED
|
@@ -100,13 +100,12 @@ class Abba {
|
|
|
100
100
|
async getUserAssignment(experimentId, userId, existingOnly, segmentationData) {
|
|
101
101
|
const existing = await this.getExistingUserAssignment(experimentId, userId);
|
|
102
102
|
if (existing) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
};
|
|
103
|
+
let bucketKey = null;
|
|
104
|
+
if (existing.bucketId) {
|
|
105
|
+
const { key } = await this.bucketDao.requireById(existing.bucketId);
|
|
106
|
+
bucketKey = key;
|
|
107
|
+
}
|
|
108
|
+
return { ...existing, bucketKey };
|
|
110
109
|
}
|
|
111
110
|
if (existingOnly)
|
|
112
111
|
return null;
|
|
@@ -121,7 +120,6 @@ class Abba {
|
|
|
121
120
|
const saved = await this.userAssignmentDao.save(assignment);
|
|
122
121
|
return {
|
|
123
122
|
...saved,
|
|
124
|
-
experimentName: experiment.name,
|
|
125
123
|
bucketKey: buckets.find(b => b.id === saved.bucketId)?.key || null,
|
|
126
124
|
};
|
|
127
125
|
}
|
|
@@ -158,7 +156,6 @@ class Abba {
|
|
|
158
156
|
if (existing) {
|
|
159
157
|
assignments.push({
|
|
160
158
|
...existing,
|
|
161
|
-
experimentName: experiment.name,
|
|
162
159
|
bucketKey: experiment.buckets.find(i => i.id === existing.bucketId)?.key || null,
|
|
163
160
|
});
|
|
164
161
|
}
|
package/dist/migrations/init.sql
CHANGED
|
@@ -13,7 +13,6 @@ CREATE TABLE IF NOT EXISTS `Bucket` (
|
|
|
13
13
|
-- CreateTable
|
|
14
14
|
CREATE TABLE IF NOT EXISTS `Experiment` (
|
|
15
15
|
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
|
16
|
-
`name` VARCHAR(191) NOT NULL,
|
|
17
16
|
`status` INTEGER NOT NULL,
|
|
18
17
|
`sampling` INTEGER NOT NULL,
|
|
19
18
|
`description` VARCHAR(240) NULL,
|
package/dist/types.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export interface AbbaConfig {
|
|
|
4
4
|
db: CommonDB;
|
|
5
5
|
}
|
|
6
6
|
export declare type BaseExperiment = BaseDBEntity<number> & {
|
|
7
|
-
|
|
7
|
+
id: number;
|
|
8
8
|
status: number;
|
|
9
9
|
sampling: number;
|
|
10
10
|
description: string | null;
|
|
@@ -31,7 +31,6 @@ export declare type UserAssignment = BaseDBEntity<number> & {
|
|
|
31
31
|
bucketId: number | null;
|
|
32
32
|
};
|
|
33
33
|
export declare type GeneratedUserAssignment = Saved<UserAssignment> & {
|
|
34
|
-
experimentName: string;
|
|
35
34
|
bucketKey: string | null;
|
|
36
35
|
};
|
|
37
36
|
export declare type SegmentationData = Record<string, string | boolean | number>;
|
package/package.json
CHANGED
package/src/abba.ts
CHANGED
|
@@ -97,7 +97,7 @@ export class Abba {
|
|
|
97
97
|
return {
|
|
98
98
|
...(experiment as Saved<Experiment>),
|
|
99
99
|
buckets: await this.bucketDao.saveBatch(
|
|
100
|
-
buckets.map(b => ({ ...b, experimentId: experiment.id
|
|
100
|
+
buckets.map(b => ({ ...b, experimentId: experiment.id })),
|
|
101
101
|
),
|
|
102
102
|
}
|
|
103
103
|
}
|
|
@@ -150,13 +150,12 @@ export class Abba {
|
|
|
150
150
|
const existing = await this.getExistingUserAssignment(experimentId, userId)
|
|
151
151
|
|
|
152
152
|
if (existing) {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
experimentName: experiment.name,
|
|
158
|
-
bucketKey: bucket?.key || null,
|
|
153
|
+
let bucketKey = null
|
|
154
|
+
if (existing.bucketId) {
|
|
155
|
+
const { key } = await this.bucketDao.requireById(existing.bucketId)
|
|
156
|
+
bucketKey = key
|
|
159
157
|
}
|
|
158
|
+
return { ...existing, bucketKey }
|
|
160
159
|
}
|
|
161
160
|
|
|
162
161
|
if (existingOnly) return null
|
|
@@ -179,7 +178,6 @@ export class Abba {
|
|
|
179
178
|
|
|
180
179
|
return {
|
|
181
180
|
...saved,
|
|
182
|
-
experimentName: experiment.name,
|
|
183
181
|
bucketKey: buckets.find(b => b.id === saved.bucketId)?.key || null,
|
|
184
182
|
}
|
|
185
183
|
}
|
|
@@ -224,7 +222,6 @@ export class Abba {
|
|
|
224
222
|
if (existing) {
|
|
225
223
|
assignments.push({
|
|
226
224
|
...existing,
|
|
227
|
-
experimentName: experiment.name,
|
|
228
225
|
bucketKey: experiment.buckets.find(i => i.id === existing.bucketId)?.key || null,
|
|
229
226
|
})
|
|
230
227
|
}
|
package/src/migrations/init.sql
CHANGED
|
@@ -13,7 +13,6 @@ CREATE TABLE IF NOT EXISTS `Bucket` (
|
|
|
13
13
|
-- CreateTable
|
|
14
14
|
CREATE TABLE IF NOT EXISTS `Experiment` (
|
|
15
15
|
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
|
16
|
-
`name` VARCHAR(191) NOT NULL,
|
|
17
16
|
`status` INTEGER NOT NULL,
|
|
18
17
|
`sampling` INTEGER NOT NULL,
|
|
19
18
|
`description` VARCHAR(240) NULL,
|
package/src/types.ts
CHANGED
|
@@ -14,7 +14,7 @@ export interface AbbaConfig {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export type BaseExperiment = BaseDBEntity<number> & {
|
|
17
|
-
|
|
17
|
+
id: number
|
|
18
18
|
status: number
|
|
19
19
|
sampling: number
|
|
20
20
|
description: string | null
|
|
@@ -47,7 +47,6 @@ export type UserAssignment = BaseDBEntity<number> & {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
export type GeneratedUserAssignment = Saved<UserAssignment> & {
|
|
50
|
-
experimentName: string
|
|
51
50
|
bucketKey: string | null
|
|
52
51
|
}
|
|
53
52
|
|