mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-01 07:21:15 +00:00
remove preen-database in schema.coffee, we'll do that on a different branch
This commit is contained in:
parent
55975dfc5f
commit
c91b628adf
1 changed files with 1 additions and 34 deletions
|
|
@ -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
|
||||
Loading…
Reference in a new issue