diff options
| author | Karsten Loesing <karsten.loesing@gmx.net> | 2020-01-19 11:13:19 +0100 |
|---|---|---|
| committer | Karsten Loesing <karsten.loesing@gmx.net> | 2020-01-19 11:13:19 +0100 |
| commit | 87abfdd1d939d0cdbeece01a15a07ded850af799 (patch) | |
| tree | a635f854ef3c6522591c455bc5c6a121aa4864b4 | |
| parent | 79626a16ccd6d4e61ee37b10422cb3af9aec4dbe (diff) | |
Also include somewhat redundant graph histories.
Fixes #28871.
| -rw-r--r-- | CHANGELOG.md | 8 | ||||
| -rw-r--r-- | src/main/java/org/torproject/metrics/onionoo/writer/GraphHistoryCompiler.java | 23 |
2 files changed, 21 insertions, 10 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bf4466..b56690d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +# Changes in version 8.0-1.2?.? - 20??-??-?? + + * Major changes + - Include graph history objects even if the time period they cover + are already contained in other graph history objects with shorter + time periods and higher data resolutions. + + # Changes in version 7.0-1.2?.? - 20??-??-?? * Minor changes diff --git a/src/main/java/org/torproject/metrics/onionoo/writer/GraphHistoryCompiler.java b/src/main/java/org/torproject/metrics/onionoo/writer/GraphHistoryCompiler.java index ae5231f..a9227bb 100644 --- a/src/main/java/org/torproject/metrics/onionoo/writer/GraphHistoryCompiler.java +++ b/src/main/java/org/torproject/metrics/onionoo/writer/GraphHistoryCompiler.java @@ -125,11 +125,18 @@ public class GraphHistoryCompiler { /* Iterate over all history entries and see which ones we need for this * graph. */ + boolean compileNextGraph = false; for (Map.Entry<long[], Double> h : this.history.entrySet()) { long startMillis = h.getKey()[0]; long endMillis = h.getKey()[1]; double value = h.getValue(); + /* If the history entry starts before this graph starts, remember that + * we'll have to compile the next graph. */ + if (startMillis <= graphStartMillis) { + compileNextGraph = true; + } + /* If a history entry ends before this graph starts or starts before * this graph ends, skip it. */ if (endMillis <= graphStartMillis || startMillis >= graphEndMillis) { @@ -211,16 +218,6 @@ public class GraphHistoryCompiler { long firstDataPointMillis = graphStartMillis + firstNonNullIndex * dataPointInterval + dataPointInterval / 2L; - /* If the graph doesn't contain anything new that wasn't already contained - * in previously compiled graphs, skip this graph. */ - if (graphIntervalIndex > 0 && !graphs.isEmpty() - && firstDataPointMillis >= LocalDateTime.ofEpochSecond( - graphEndMillis / 1000L, 0, ZoneOffset.UTC) - .minus(this.graphIntervals.get(graphIntervalIndex - 1)) - .toEpochSecond(ZoneOffset.UTC) * 1000L) { - continue; - } - /* Put together the list of values that will go into the graph. */ List<Integer> values = new ArrayList<>(); for (int dataPointIndex = firstNonNullIndex; @@ -245,6 +242,12 @@ public class GraphHistoryCompiler { graphHistory.setCount(lastNonNullIndex - firstNonNullIndex + 1); graphHistory.setValues(values); graphs.put(graphName, graphHistory); + + /* If all history entries ended after this graph started, stop compiling + * more graphs for this history. */ + if (!compileNextGraph) { + break; + } } /* We're done. Return the map of compiled graphs. */ |
