remove preen-database in schema.coffee, we'll do that on a different branch

This commit is contained in:
Tyler Renelle 2013-01-22 13:41:53 -05:00
parent 55975dfc5f
commit c91b628adf

View file

@ -23,37 +23,4 @@ module.exports.userSchema = ->
when 'daily' then newUser.dailyIds.push guid
when 'todo' then newUser.todoIds.push guid
when 'reward' then newUser.rewardIds.push guid
return newUser
module.exports.updateSchema = (model) ->
return # not using, will revisit this later
# Reset history, remove inactive users
model.fetch 'users', (err, users) ->
_.each users.get(), (userObj) ->
userPath = "users.#{userObj._id}"
user = model.at(userPath)
# Remove inactive users
# remove if they don't have a lastCron (older accounts didn't)
unless userObj.lastCron?
model.del(userPath)
return
# Remove all users who haven't logged in for a month
daysOld = helpers.daysBetween(new Date(), userObj.lastCron)
if daysOld > 30
# and who have mostly the default tasks
sameTasks = _.filter require('./content').defaultTasks, (defaultTask) ->
foundSame = _.find userObj.tasks, (userTask) ->
userTask.text == defaultTask.text
return foundSame?
if _.size(sameTasks)>5
model.del(userPath)
return
# Reset all history
user.set 'history', {exp:[], todos:[]}
_.each userObj.tasks, (taskObj) ->
task = user.at "tasks.#{taskObj.id}"
if task.get("history")
task.set "history", []
return newUser