2016-06-23 11:40:35 +09:00
|
|
|
import Posts from "meteor/nova:posts";
|
|
|
|
|
2015-04-22 08:31:11 +09:00
|
|
|
Meteor.startup(function () {
|
2016-03-21 10:27:43 +09:00
|
|
|
var scoreInterval = Telescope.settings.get("scoreUpdateInterval") || 30;
|
2015-04-22 08:31:11 +09:00
|
|
|
if (scoreInterval > 0) {
|
|
|
|
|
|
|
|
// active items get updated every N seconds
|
2015-05-01 18:22:00 +02:00
|
|
|
Meteor.setInterval(function () {
|
2016-03-22 10:38:57 +09:00
|
|
|
|
2015-04-22 08:31:11 +09:00
|
|
|
var updatedPosts = 0;
|
|
|
|
var updatedComments = 0;
|
|
|
|
// console.log('tick ('+scoreInterval+')');
|
|
|
|
Posts.find({'status': 2,'inactive': {$ne : true}}).forEach(function (post) { // only run scoring on approved posts
|
2015-04-23 11:11:07 +09:00
|
|
|
updatedPosts += Telescope.updateScore({collection: Posts, item: post});
|
2015-04-22 08:31:11 +09:00
|
|
|
});
|
|
|
|
Comments.find({'inactive': {$ne : true}}).forEach(function (comment) {
|
2015-04-23 11:11:07 +09:00
|
|
|
updatedComments += Telescope.updateScore({collection: Comments, item: comment});
|
2015-04-22 08:31:11 +09:00
|
|
|
});
|
|
|
|
// console.log("Updated "+updatedPosts+"/"+Posts.find().count()+" Posts")
|
|
|
|
// console.log("Updated "+updatedComments+"/"+Comments.find().count()+" Comments")
|
|
|
|
}, scoreInterval * 1000);
|
|
|
|
|
|
|
|
// inactive items get updated every hour
|
2015-05-01 18:22:00 +02:00
|
|
|
Meteor.setInterval(function () {
|
2015-04-22 08:31:11 +09:00
|
|
|
var updatedPosts = 0;
|
|
|
|
var updatedComments = 0;
|
|
|
|
Posts.find({'inactive': true}).forEach(function (post) {
|
2015-04-23 11:11:07 +09:00
|
|
|
updatedPosts += Telescope.updateScore({collection: Posts, item: post});
|
2015-04-22 08:31:11 +09:00
|
|
|
});
|
|
|
|
Comments.find({'inactive': true}).forEach(function (comment) {
|
2015-04-23 11:11:07 +09:00
|
|
|
updatedComments += Telescope.updateScore({collection: Comments, item: comment});
|
2015-04-22 08:31:11 +09:00
|
|
|
});
|
|
|
|
}, 3600 * 1000);
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|