make-mp-data 1.1.16 → 1.1.18

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/index.js CHANGED
@@ -479,8 +479,8 @@ function AKsTimeSoup(earliestTime, latestTime = NOW, peakDays = PEAK_DAYS) {
479
479
 
480
480
  if (typeof earliestTime !== "number") {
481
481
  if (parseInt(earliestTime) > 0) earliestTime = parseInt(earliestTime);
482
- if (dayjs(earliestTime).isValid()) earliestTime = dayjs(earliestTime).unix();
483
- }
482
+ if (dayjs(earliestTime).isValid()) earliestTime = dayjs(earliestTime).unix();
483
+ }
484
484
 
485
485
  while (!validTime) {
486
486
 
@@ -506,7 +506,7 @@ function AKsTimeSoup(earliestTime, latestTime = NOW, peakDays = PEAK_DAYS) {
506
506
  // Generate a random time within business hours with a higher concentration in the middle of the period
507
507
  const businessStart = dayjs.unix(selectedDay).hour(peakStartHour).minute(0).second(0).unix();
508
508
  const businessEnd = dayjs.unix(selectedDay).hour(peakEndHour).minute(0).second(0).unix();
509
-
509
+
510
510
  if (selectedDay === peakDays[0]) {
511
511
  // Use a skewed distribution for peak days
512
512
  eventTime = chance.normal({ mean: (businessEnd + businessStart) / integer(1, 4), dev: (businessEnd - businessStart) / integer(2, 8) });
@@ -518,8 +518,10 @@ function AKsTimeSoup(earliestTime, latestTime = NOW, peakDays = PEAK_DAYS) {
518
518
  // usually, ensure the event time is within business hours
519
519
  if (chance.bool({ likelihood: 42 })) eventTime = Math.min(Math.max(eventTime, businessStart), businessEnd);
520
520
 
521
- const compareTime = dayjs.unix(eventTime).toISOString();
522
- if (dayjs(chosenTime).isAfter(dayjs.unix(0))) validTime = true;
521
+ if (eventTime > 0) validTime = true;
522
+ const parsedTime = dayjs.unix(eventTime).toISOString();
523
+ if (!parsedTime.startsWith('20')) validTime = false;
524
+
523
525
  }
524
526
  chosenTime = dayjs.unix(eventTime).toISOString();
525
527
  return chosenTime;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "make-mp-data",
3
- "version": "1.1.16",
3
+ "version": "1.1.18",
4
4
  "description": "builds all mixpanel primitives for a given project",
5
5
  "main": "index.js",
6
6
  "types": "types.d.ts",
@@ -10,7 +10,7 @@ require('dotenv').config();
10
10
  describe('timeSoup', () => {
11
11
  test('always positive dates', () => {
12
12
  const dates = [];
13
- for (let i = 0; i < 10000; i++) {
13
+ for (let i = 0; i < 20000; i++) {
14
14
  const earliest = dayjs().subtract(u.rand(2, 360), 'D');
15
15
  dates.push(timeSoup());
16
16
  }