Merge branch 'develop' into release

This commit is contained in:
Sabe Jones
2021-10-28 13:55:11 -05:00
71 changed files with 2295 additions and 1729 deletions

View File

@@ -688,6 +688,8 @@ api.updateTask = {
-user.preferences.timezoneOffset,
).date()];
}
if (task.streak === undefined) task.streak = 0;
task.streak = Math.trunc(task.streak);
}
setNextDue(task, user);

View File

@@ -25,7 +25,6 @@ async function checkForActiveCron (user, now) {
}, {
$set: {
_cronSignature,
'auth.timestamps.loggedin': now,
},
}).exec();
@@ -66,7 +65,6 @@ async function cronAsync (req, res) {
res.locals.user = user;
const { daysMissed, timezoneUtcOffsetFromUserPrefs } = user.daysUserHasMissed(now, req);
user.enrollInDropCapABTest(req.headers['x-client']);
await updateLastCron(user, now);
if (daysMissed <= 0) {
@@ -143,6 +141,7 @@ async function cronAsync (req, res) {
}, {
$set: {
_cronSignature: 'NOT_RUNNING',
'auth.timestamps.loggedin': now,
},
}).exec();

View File

@@ -525,21 +525,3 @@ schema.methods.getSecretData = function getSecretData () {
return user.secret;
};
// Enroll users in the Drop Cap A/B Test
schema.methods.enrollInDropCapABTest = function enrollInDropCapABTest (xClientHeader) {
// Only target users that use web for cron and aren't subscribed.
// Those using mobile aren't excluded as they may use it later
const isWeb = xClientHeader === 'habitica-web';
if (isWeb && !this._ABtests.dropCapNotif && !this.isSubscribed()) {
const testGroup = Math.random();
// Enroll 100% of users, splitting them 50/50
if (testGroup <= 0.50) {
this._ABtests.dropCapNotif = 'drop-cap-notif-enabled';
} else {
this._ABtests.dropCapNotif = 'drop-cap-notif-disabled';
}
this.markModified('_ABtests');
}
};