You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.2 KiB

var jsoncompress = require('jsoncompress');
var cycleAdd = require("./interop").cycleAdd;
var cycleAcc = require("./interop").cycleAcc;
function Cycle()
{
this.last =0; //last post number of this cycle
this.number = 0; //number of new posts this cycle
this.countries = {}; //stored as <code>: <number of times>
this.namefags = {}; //stored as <name>: <number of times>
this.timestamp = new Date()
this.threads=0; //number of new threads
this.interval=0; //average time between posts
this.comments=0; //number of posts with comments
this.subjects=0; //number of posts with subjects
this.images=0; //number of posts with images
this.names=0;//number of posts with names
this.trips = 0;//number of posts with tripcodes
this.nametrips = 0; //number of name+tripfags
this.ids =0; //post ids
}
Cycle.prototype.serialise = function() {
return jsoncompress.compress(this, new Cycle());
};
Cycle.unserialise = function(data) {
return jsoncompress.decompress(data, new Cycle());
};
Cycle.accumulate = function(ar) {
var ret = new Cycle();
return cycleAdd(ret, ar);
};
Cycle.average = function(st, ar, n) {
var ret = st;
return cycleAcc(ret, ar,n);
};
module.exports.Cycle = Cycle;