Merge branch 'master' into parties

Conflicts:
	migrations/20130129_add_missing_preferences.js
This commit is contained in:
Tyler Renelle 2013-01-31 22:19:37 -05:00
commit 4253e12f36
3 changed files with 9 additions and 5 deletions

View file

@ -1,5 +1,5 @@
db.users.update(
{'preferences':{$exists:false}},
{preferences:{$exists:false}},
{$set:{preferences:{gender: 'm', armorSet: 'v1'}}},
{multi:true}
)

View file

@ -56,4 +56,5 @@ module.exports.updateUser = (user, userObj) ->
preened = _.filter(union, (val) -> _.contains(taskIds, val))
# There were indeed issues found, set the new list
user.set(path, preened) if _.size(preened) != _.size(userObj[path])
# TODO _.difference might still be empty for duplicates in one list?
user.set(path, preened) if _.difference(preened, userObj[path]).length != 0

View file

@ -10,7 +10,7 @@ _ = require('underscore')
module.exports.deleteStaleAccounts = ->
un_registered = { "auth.local": {$exists: false} , "auth.facebook": {$exists: false} }
registered = registered = { $or: [
registered = { $or: [
{ 'auth.local': { $exists: true } },
{ 'auth.facebook': { $exists: true} }
]};
@ -34,5 +34,8 @@ module.exports.deleteStaleAccounts = ->
if !!user.lastCron # for now ignore missing crons, still looking into why this is happening
lastCron = new Date(user.lastCron)
diff = Math.abs(moment(today).sod().diff(moment(lastCron).sod(), "days"))
if diff > 30
if diff > 10
removeAccount(collection, user._id)
else
# cron was missing for some reason
collection.update {_id: user._id}, {$set:{lastCron: today}}, (err, res) -> throw err if err