@naturalcycles/abba 1.18.3 → 1.18.5
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/util.js +1 -1
- package/package.json +2 -4
- package/src/abba.ts +2 -2
- package/src/util.ts +3 -3
package/dist/abba.js
CHANGED
|
@@ -12,7 +12,7 @@ const util_1 = require("./util");
|
|
|
12
12
|
/**
|
|
13
13
|
* 10 minutes
|
|
14
14
|
*/
|
|
15
|
-
const CACHE_TTL =
|
|
15
|
+
const CACHE_TTL = 600_000; // 10 minutes
|
|
16
16
|
class Abba {
|
|
17
17
|
constructor(cfg) {
|
|
18
18
|
this.cfg = cfg;
|
|
@@ -240,5 +240,5 @@ class Abba {
|
|
|
240
240
|
}
|
|
241
241
|
exports.Abba = Abba;
|
|
242
242
|
tslib_1.__decorate([
|
|
243
|
-
(0, js_lib_1.
|
|
243
|
+
(0, js_lib_1._Memo)({ cacheFactory: () => new nodejs_lib_1.LRUMemoCache({ ttl: CACHE_TTL, max: 1 }) })
|
|
244
244
|
], Abba.prototype, "getAllExperiments", null);
|
package/dist/util.js
CHANGED
|
@@ -124,7 +124,7 @@ exports.segmentationRuleMap = {
|
|
|
124
124
|
const canGenerateNewAssignments = (experiment, exclusionSet) => {
|
|
125
125
|
return (!exclusionSet.has(experiment.id) &&
|
|
126
126
|
experiment.status === types_1.AssignmentStatus.Active &&
|
|
127
|
-
(0, js_lib_1.
|
|
127
|
+
(0, js_lib_1._isBetween)((0, js_lib_1.todayString)(), experiment.startDateIncl, experiment.endDateExcl, '[)'));
|
|
128
128
|
};
|
|
129
129
|
exports.canGenerateNewAssignments = canGenerateNewAssignments;
|
|
130
130
|
/**
|
package/package.json
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/abba",
|
|
3
|
-
"version": "1.18.
|
|
3
|
+
"version": "1.18.5",
|
|
4
4
|
"scripts": {
|
|
5
|
-
"prepare": "husky
|
|
6
|
-
"build": "build",
|
|
7
|
-
"build-prod": "build-prod"
|
|
5
|
+
"prepare": "husky"
|
|
8
6
|
},
|
|
9
7
|
"dependencies": {
|
|
10
8
|
"@naturalcycles/db-lib": "^9.1.0",
|
package/src/abba.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _assert,
|
|
1
|
+
import { _assert, _Memo, _shuffle, pMap } from '@naturalcycles/js-lib'
|
|
2
2
|
import { LRUMemoCache } from '@naturalcycles/nodejs-lib'
|
|
3
3
|
import { bucketDao } from './dao/bucket.dao'
|
|
4
4
|
import { experimentDao } from './dao/experiment.dao'
|
|
@@ -38,7 +38,7 @@ export class Abba {
|
|
|
38
38
|
* Returns all experiments.
|
|
39
39
|
* Cached (see CACHE_TTL)
|
|
40
40
|
*/
|
|
41
|
-
@
|
|
41
|
+
@_Memo({ cacheFactory: () => new LRUMemoCache({ ttl: CACHE_TTL, max: 1 }) })
|
|
42
42
|
async getAllExperiments(): Promise<ExperimentWithBuckets[]> {
|
|
43
43
|
return await this.getAllExperimentsNoCache()
|
|
44
44
|
}
|
package/src/util.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _isBetween, Saved, todayString } from '@naturalcycles/js-lib'
|
|
2
2
|
import { satisfies } from 'semver'
|
|
3
3
|
import {
|
|
4
4
|
AssignmentStatus,
|
|
@@ -31,7 +31,7 @@ export const generateUserAssignmentData = (
|
|
|
31
31
|
userId,
|
|
32
32
|
experimentId: experiment.id,
|
|
33
33
|
bucketId: bucket?.id || null,
|
|
34
|
-
}
|
|
34
|
+
} as UserAssignment
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
/**
|
|
@@ -147,7 +147,7 @@ export const canGenerateNewAssignments = (
|
|
|
147
147
|
return (
|
|
148
148
|
!exclusionSet.has(experiment.id) &&
|
|
149
149
|
experiment.status === AssignmentStatus.Active &&
|
|
150
|
-
|
|
150
|
+
_isBetween(todayString(), experiment.startDateIncl, experiment.endDateExcl, '[)')
|
|
151
151
|
)
|
|
152
152
|
}
|
|
153
153
|
|