forked from codeforboston/mbta-ninja
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
34 lines (29 loc) · 897 Bytes
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
if (Meteor.isServer) {
Meteor.startup(function() {});
// Task to expire old reports. It checks every minute to see if there are
// tasks reported/confirmed more than 30 minutes ago.
var intervalDecay = -1; // How many points subtracted per interval
SyncedCron.add({
name: 'Expire old reports',
schedule: function(parser) {
return parser.text('every 1 minute');
},
job: function() {
// Decay weight
Reports.update(
{expired: false},
{$inc: {weight: intervalDecay}},
{multi: true}
);
// Expire the ones with 0 or negative weights
Reports.update(
{weight: {$lte: 0}},
{$set: {expired: true}},
{multi: true}
);
var activeRemaining = Reports.find({expired: false}).count()
console.log(activeRemaining + " active reports remaining.")
}
});
SyncedCron.start();
}