challenges: remove derby stuff

This commit is contained in:
Tyler Renelle 2013-10-26 10:23:39 -07:00
parent 72bf5d7073
commit 91c1bd2ddb
2 changed files with 27 additions and 40 deletions

View file

@ -8023,11 +8023,8 @@ var process=require("__browserify_process");(function() {
}
return task;
},
newUser: function(isDerby) {
newUser: function() {
var defaultTags, defaultTasks, guid, newUser, repeat, tag, task, userSchema, _i, _j, _len, _len1;
if (isDerby == null) {
isDerby = false;
}
userSchema = {
stats: {
gp: 0,
@ -8063,18 +8060,10 @@ var process=require("__browserify_process");(function() {
},
tags: []
};
if (isDerby) {
userSchema.habitIds = [];
userSchema.dailyIds = [];
userSchema.todoIds = [];
userSchema.rewardIds = [];
userSchema.tasks = {};
} else {
userSchema.habits = [];
userSchema.dailys = [];
userSchema.todos = [];
userSchema.rewards = [];
}
userSchema.habits = [];
userSchema.dailys = [];
userSchema.todos = [];
userSchema.rewards = [];
newUser = _.cloneDeep(userSchema);
repeat = {
m: true,
@ -8158,12 +8147,7 @@ var process=require("__browserify_process");(function() {
for (_i = 0, _len = defaultTasks.length; _i < _len; _i++) {
task = defaultTasks[_i];
guid = task.id = uuid();
if (isDerby) {
newUser.tasks[guid] = task;
newUser["" + task.type + "Ids"].push(guid);
} else {
newUser["" + task.type + "s"].push(task);
}
newUser["" + task.type + "s"].push(task);
}
for (_j = 0, _len1 = defaultTags.length; _j < _len1; _j++) {
tag = defaultTags[_j];
@ -8394,9 +8378,21 @@ var process=require("__browserify_process");(function() {
taskClasses: function(task, filters, dayStart, lastCron, showCompleted, main) {
var classes, completed, enabled, filter, repeat, type, value, _ref;
if (filters == null) {
filters = [];
}
if (dayStart == null) {
dayStart = 0;
}
if (lastCron == null) {
lastCron = +(new Date);
}
if (showCompleted == null) {
showCompleted = false;
}
if (main == null) {
main = false;
}
if (!task) {
return;
}

View file

@ -71,7 +71,9 @@ module.exports =
task.value ?= if task.type is 'reward' then 10 else 0
task
newUser: (isDerby=false) ->
# FIXME - should we remove this completely, since all defaults are accounted for in mongoose?
# Or should we keep it so mobile can create an offline new user in the future?
newUser: () ->
userSchema =
# _id / id handled by Racer
stats: { gp: 0, exp: 0, lvl: 1, hp: 50 }
@ -87,17 +89,10 @@ module.exports =
ads: 'show'
tags: []
if isDerby
userSchema.habitIds = []
userSchema.dailyIds = []
userSchema.todoIds = []
userSchema.rewardIds = []
userSchema.tasks = {}
else
userSchema.habits = []
userSchema.dailys = []
userSchema.todos = []
userSchema.rewards = []
userSchema.habits = []
userSchema.dailys = []
userSchema.todos = []
userSchema.rewards = []
# deep clone, else further new users get duplicate objects
newUser = _.cloneDeep userSchema
@ -126,11 +121,7 @@ module.exports =
for task in defaultTasks
guid = task.id = uuid()
if isDerby
newUser.tasks[guid] = task
newUser["#{task.type}Ids"].push guid
else
newUser["#{task.type}s"].push task
newUser["#{task.type}s"].push task
for tag in defaultTags
tag.id = uuid()
@ -276,7 +267,7 @@ module.exports =
###
Task classes given everything about the class
###
taskClasses: (task, filters, dayStart, lastCron, showCompleted=false, main) ->
taskClasses: (task, filters=[], dayStart=0, lastCron=+new Date, showCompleted=false, main=false) ->
return unless task
{type, completed, value, repeat} = task