From 43f8eb0a5c38f5e129a58ae29ccb946b74680336 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Thu, 3 Oct 2013 08:30:32 -0700 Subject: [PATCH] Fix zero-fill logic in graphs Add zero-padding to the end of of the graphs up to the present time so they continue to move left even if there are no new hits (the current behavior shows a graph from the first to the last hit). Also, fix an OBOB with the zero-fill between hits. Change-Id: I1938b779e0c5c383f4a7b1eb9a63dd5401cc9889 --- elastic_recheck/cmd/graph.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/elastic_recheck/cmd/graph.py b/elastic_recheck/cmd/graph.py index 7b23c8e3..8f533fc5 100755 --- a/elastic_recheck/cmd/graph.py +++ b/elastic_recheck/cmd/graph.py @@ -78,6 +78,11 @@ def main(): hist[pos] = 0 hist[pos] += 1 + ts = datetime.now() + ts = datetime(ts.year, ts.month, ts.day, ts.hour) + # ms since epoch + now = int(((ts - epoch).total_seconds()) * 1000) + for name, hist in histograms.items(): d = dict(label=name, data=[]) @@ -86,12 +91,14 @@ def main(): last = None for pos in positions: if last is not None: - prev = pos - 3600000 - if prev > last: - for i in range(last, prev, 3600000): + if last + 3600000 < pos: + for i in range(last + 3600000, pos, 3600000): d['data'].append([i, 0]) d['data'].append([pos, hist[pos]]) last = pos + if last + 3600000 < now: + for i in range(last + 3600000, now, 3600000): + d['data'].append([i, 0]) bug['data'].append(d) out = open(args.output, 'w')