Vulcan/server/scoring.js

35 lines
1.4 KiB
JavaScript
Raw Normal View History

2012-09-27 13:13:55 -07:00
Meteor.startup(function () {
2012-11-21 12:30:45 +09:00
var scoreInterval = getSetting("scoreUpdateInterval") || 30;
if (scoreInterval > 0) {
2012-12-24 16:21:56 +01:00
// active items get updated every N seconds
intervalId = Meteor.setInterval(function () {
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
updatedPosts += updateScore({collection: Posts, item: post});
});
Comments.find({'inactive': {$ne : true}}).forEach(function (comment) {
updatedComments += updateScore({collection: Comments, item: comment});
});
// 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
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) {
updatedPosts += updateScore({collection: Posts, item: post});
2012-12-24 16:21:56 +01:00
});
Comments.find({'inactive': true}).forEach(function (comment) {
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
});