0

I am trying to fetch data from a db every 10 mins where the data is inserted with a timestamp. Now using this timestamp i want to visualize another field. The visualization has a step size of 10 mins. So it checks from the start till the stop time to find any match. Here is the code -

while((i += step) < stop) {
    var key = (new Date(i)).getTime();
    var value = key in lookup ? lookup[key].gtse: null;
    values.push(value);
}
callback(null, values);

My problem is that the timestamp which is fetched from DB never matches. Here is some data to make it clear.

The key values - 
    1st iteration - 1372168200000 
    2nd iteration - 1372168800000 
The database fetched value - 1372786393088

So in this case the key never matches when it is iterating over lookup. If i dont use step and change the while loop to while((i += 1) < stop) then the browser hangs since there is lot of processing after this.

Should i manipulate the date before db insertion and change the trailing 5-6 places to zero or should i handle this on the client side?

I need some advice how to tackle this.

Dan
  • 801
  • 2
  • 14
  • 29
  • 1
    you want to go the other way: loop through the db data match it up to the client data, finding the closest match and using > instead of 'in' or ==. – dandavis Jul 03 '13 at 16:29
  • thank you, just got a little impatient. – Dan Jul 05 '13 at 14:53

0 Answers0