v3: first review of common code and task models
This commit is contained in:
@@ -197,7 +197,7 @@ module.exports = function scoreTask (options = {}, req = {}) {
|
||||
|
||||
// Add history entry, even more than 1 per day
|
||||
task.history.push({
|
||||
date: Number(new Date()), // TODO are we going to cast history entries?
|
||||
date: Number(new Date()),
|
||||
value: task.value,
|
||||
});
|
||||
} else if (task.type === 'daily') {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import i18n from '../i18n';
|
||||
import _ from 'lodash';
|
||||
import splitWhitespace from '../libs/splitWhitespace';
|
||||
import dotSet from '../libs/dotSet';
|
||||
import {
|
||||
NotAuthorized,
|
||||
BadRequest,
|
||||
@@ -37,11 +36,11 @@ module.exports = function unlock (user, req = {}, analytics) {
|
||||
if (isFullSet) {
|
||||
_.each(path.split(','), function markItemsAsPurchased (pathPart) {
|
||||
if (path.indexOf('gear.') !== -1) {
|
||||
dotSet(user, pathPart, true);
|
||||
_.set(user, pathPart, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
dotSet(user, `purchased.${pathPart}`, true);
|
||||
_.set(user, `purchased.${pathPart}`, true);
|
||||
return true;
|
||||
});
|
||||
} else {
|
||||
@@ -52,11 +51,11 @@ module.exports = function unlock (user, req = {}, analytics) {
|
||||
if (key === 'background' && value === user.preferences.background) {
|
||||
value = '';
|
||||
}
|
||||
dotSet(user, `preferences.${key}`, value);
|
||||
_.set(user, `preferences.${key}`, value);
|
||||
|
||||
throw new NotAuthorized(i18n.t('alreadyUnlocked', req.language));
|
||||
}
|
||||
dotSet(user, `purchased.${path}`, true);
|
||||
_.set(user, `purchased.${path}`, true);
|
||||
}
|
||||
|
||||
if (path.indexOf('gear.') === -1) {
|
||||
|
||||
Reference in New Issue
Block a user