2012-09-27 13:13:55 -07:00
|
|
|
|
|
|
|
Meteor.startup(function () {
|
2012-11-21 12:30:45 +09:00
|
|
|
var scoreInterval = getSetting("scoreUpdateInterval") || 30;
|
2014-09-16 15:18:27 -04:00
|
|
|
if (scoreInterval > 0) {
|
2012-12-24 16:21:56 +01:00
|
|
|
|
|
|
|
// active items get updated every N seconds
|
2014-09-16 15:18:27 -04:00
|
|
|
intervalId = Meteor.setInterval(function () {
|
2012-12-23 17:25:03 +01:00
|
|
|
var updatedPosts = 0;
|
|
|
|
var updatedComments = 0;
|
2012-10-23 12:24:38 +09:00
|
|
|
// console.log('tick ('+scoreInterval+')');
|
2014-07-03 13:15:23 +09:00
|
|
|
Posts.find({'status': 2,'inactive': {$ne : true}}).forEach(function (post) { // only run scoring on approved posts
|
2014-01-25 14:11:26 -05:00
|
|
|
updatedPosts += updateScore({collection: Posts, item: post});
|
2012-12-23 17:25:03 +01:00
|
|
|
});
|
2012-12-24 10:59:13 +01:00
|
|
|
Comments.find({'inactive': {$ne : true}}).forEach(function (comment) {
|
2014-01-25 14:11:26 -05:00
|
|
|
updatedComments += updateScore({collection: Comments, item: comment});
|
2012-12-23 17:25:03 +01:00
|
|
|
});
|
2012-12-31 18:18:46 +01:00
|
|
|
// console.log("Updated "+updatedPosts+"/"+Posts.find().count()+" Posts")
|
|
|
|
// console.log("Updated "+updatedComments+"/"+Comments.find().count()+" Comments")
|
2012-10-22 14:00:47 +09:00
|
|
|
}, scoreInterval * 1000);
|
2012-12-24 16:21:56 +01:00
|
|
|
|
|
|
|
// inactive items get updated every hour
|
2014-09-16 15:18:27 -04:00
|
|
|
inactiveIntervalId = Meteor.setInterval(function () {
|
2013-01-11 11:17:24 +09:00
|
|
|
var updatedPosts = 0;
|
|
|
|
var updatedComments = 0;
|
2012-12-24 16:21:56 +01:00
|
|
|
Posts.find({'inactive': true}).forEach(function (post) {
|
2014-01-25 14:11:26 -05:00
|
|
|
updatedPosts += updateScore({collection: Posts, item: post});
|
2012-12-24 16:21:56 +01:00
|
|
|
});
|
|
|
|
Comments.find({'inactive': true}).forEach(function (comment) {
|
2014-01-25 14:11:26 -05:00
|
|
|
updatedComments += updateScore({collection: Comments, item: comment});
|
2012-12-24 16:21:56 +01:00
|
|
|
});
|
|
|
|
}, 3600 * 1000);
|
|
|
|
|
2012-10-22 14:00:47 +09:00
|
|
|
}
|
2012-09-27 13:13:55 -07:00
|
|
|
});
|