mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
Merge branch 'develop' into release
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user