var http = require('http'); var process = require('child_process'); var WebSocketServer = require("ws").Server; var events = require("events"); var jsoncompress = require('jsoncompress'); var config = require('./config'); var logger = require("./logger"); var _cycle = require("./cycle"); var CycleBuffer = require("./graphBuffer"); /// TODO: Buffer cycles. Clear them out every 24 hours /// TODO: Add total aggregate (url /total) that can be served function timeAverage(times) { if(times.length<1) return 0; else if(times.length==1) return times[0]; else { var cul=0; for(var i=0;it2) return t1-t2; else return t2-t1; } function bein(hay,nee) { return (nee in hay) || (("has_"+nee) in hay); } function createCandle(buffer) { var cdl = { number: { o:0, c:0, h:0, l:0 } }; if(buffer.length<1) return cdl; if(buffer.length<2) { cdl.number.c = cdl.number.o = cdl.number.h = cdl.number.l = buffer[0].number; return cdl; } cdl.number.l = -1; for(var i in buffer) { if(buffer[i].number>cdl.number.h) cdl.number.h = buffer[i].number; if(buffer[i].numberlastNumber) lastNumber = json[i].no; cycle.number+=1; if(json[i].country in cycle.countries) cycle.countries[json[i].country]+=1; else cycle.countries[json[i].country]=1; if(! ("thread" in json[i])) cycle.threads+=1; if(i