Added cron package, update scores every minute

This commit is contained in:
Tom Coleman 2012-09-20 10:59:53 +10:00
parent 3fcf344d1f
commit 24846062e1
4 changed files with 25 additions and 6 deletions

View file

@ -9,3 +9,4 @@ accounts-ui
# accounts-twitter
router
groups
cron

View file

@ -19,11 +19,22 @@ var Scoring = {
},
// rerun all the scoring
// rerun all the scoring -- TODO: should we check to see if the score has
// changed before saving?
updateScores: function() {
Posts.find().forEach(function(post) {
Scoring.updateObject(post);
Posts.update(post._id, {$set: {score: post.score}});
});
Comments.find().forEach(function(comment) {
Scoring.updateObject(comment);
Comments.update(comment._id, {$set: {score: comment.score}});
});
}
}
Meteor.Cron = new Cron();
Meteor.Cron.addJob(1, function() {
Scoring.updateScores();
})

View file

@ -4,6 +4,7 @@
},
"packages": {
"router": {},
"groups": {}
"groups": {},
"cron": {}
}
}

View file

@ -2,12 +2,13 @@
"meteor": {
"git": "https://github.com/meteor/meteor.git",
"branch": "auth",
"commit": "102880a306b1ea1b967f7a9ad208d3fa30e3a268"
"commit": "e9dcfff310c5ab2e8b968bd2b7319d3c32e3c2a1"
},
"dependencies": {
"basePackages": {
"router": {},
"groups": {}
"groups": {},
"cron": {}
},
"packages": {
"router": {
@ -17,8 +18,13 @@
},
"groups": {
"git": "https://github.com/possibilities/meteor-groups.git",
"tag": "v0.0.5",
"commit": "d79861fa9f31d885ffae02dd67ca6b2b725dcf13"
"tag": "v0.0.6",
"commit": "ee45c3fbdb84313f6f0124ed30e02e101d3829cb"
},
"cron": {
"git": "https://github.com/tmeasday/meteor-cron.git",
"tag": "v0.0.1",
"commit": "8cecc021c1fb681bfa1de2aa8242448a4516049a"
},
"deps-extensions": {
"git": "https://github.com/tmeasday/meteor-deps-extensions.git",