From 6227fc1e7c3c22e39b976222dcd4879bb0cd6f9f Mon Sep 17 00:00:00 2001 From: Thomas Baum Date: Wed, 14 Sep 2011 14:22:08 +0200 Subject: [PATCH] use seconds for monitor-requests --- .../neo4j/GraphDatabaseHeartbeat.js | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/main/javascript/neo4j/GraphDatabaseHeartbeat.js b/src/main/javascript/neo4j/GraphDatabaseHeartbeat.js index c4f261c..01fec23 100644 --- a/src/main/javascript/neo4j/GraphDatabaseHeartbeat.js +++ b/src/main/javascript/neo4j/GraphDatabaseHeartbeat.js @@ -39,18 +39,18 @@ neo4j.GraphDatabaseHeartbeat = function(db) { * These correspond to the granularities available on the server side. */ this.timespan = { - year : 1000 * 60 * 60 * 24 * 365, - month : 1000 * 60 * 60 * 24 * 31, - week : 1000 * 60 * 60 * 24 * 7, - day : 1000 * 60 * 60 * 24, - hours : 1000 * 60 * 60 * 6, - minutes : 1000 * 60 * 35 + year : 60 * 60 * 24 * 365, + month : 60 * 60 * 24 * 31, + week : 60 * 60 * 24 * 7, + day : 60 * 60 * 24, + hours : 60 * 60 * 6, + minutes : 60 * 35 }; /** * This is where the monitoring data begins. */ - this.startTimestamp = (new Date()).getTime() - this.timespan.year; + this.startTimestamp = Math.round( (new Date()).getTime() / 1000 ) - this.timespan.year; /** * This is where the monitoring data ends. @@ -265,27 +265,28 @@ neo4j.GraphDatabaseHeartbeat.prototype.waitForPulse = function(callback) { * @return {object} An object with a dataStart and a dataEnd key. */ neo4j.GraphDatabaseHeartbeat.prototype.adjustRequestedTimespan = function(data) { - var timespan = (new Date()).getTime() - this.endTimestamp; + var now = Math.round((new Date()).getTime() / 1000); + var timespan = now - this.endTimestamp; if (timespan >= this.timespan.year) { - this.endTimestamp = (new Date()).getTime() - this.timespan.month; + this.endTimestamp = now - this.timespan.month; this.beat(); } else if (timespan >= this.timespan.month) { - this.endTimestamp = (new Date()).getTime() - this.timespan.week; + this.endTimestamp = now - this.timespan.week; this.beat(); } else if (timespan >= this.timespan.week) { - this.endTimestamp = (new Date()).getTime() - this.timespan.day; + this.endTimestamp = now - this.timespan.day; this.beat(); } else if (timespan >= this.timespan.day) { - this.endTimestamp = (new Date()).getTime() - this.timespan.hours; + this.endTimestamp = now - this.timespan.hours; this.beat(); } else if (timespan >= this.timespan.day) { - this.endTimestamp = (new Date()).getTime() - this.timespan.minutes; + this.endTimestamp = now - this.timespan.minutes; this.beat(); } };