You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kibble.apache.org by hu...@apache.org on 2017/10/22 18:00:30 UTC
[kibble] branch master updated: deal with null values in timeseries
This is an automated email from the ASF dual-hosted git repository.
humbedooh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kibble.git
The following commit(s) were added to refs/heads/master by this push:
new ca18d20 deal with null values in timeseries
ca18d20 is described below
commit ca18d20f4e95252c372bb41d946c5af60931b01a
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Sun Oct 22 20:00:22 2017 +0200
deal with null values in timeseries
since not both timeseries (when distinguishing PRs and issues)
may have the same histogram, we should start by making an
empty object with both types in it, and then use that.
---
api/pages/issue/issues.py | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/api/pages/issue/issues.py b/api/pages/issue/issues.py
index e3daee9..6497feb 100644
--- a/api/pages/issue/issues.py
+++ b/api/pages/issue/issues.py
@@ -71,6 +71,15 @@ import json
import time
import hashlib
+# This creates an empty timeseries object with
+# all categories initialized as 0 opened, 0 closed.
+def makeTS(dist):
+ ts = {}
+ for k in dist:
+ ts[k + ' opened'] = 0
+ ts[k + ' closed'] = 0
+ return ts
+
def run(API, environ, indata, session):
# We need to be logged in for this!
@@ -166,7 +175,7 @@ def run(API, environ, indata, session):
for bucket in res['aggregations']['commits']['buckets']:
ts = int(bucket['key'] / 1000)
count = bucket['doc_count']
- timeseries[ts] = timeseries.get(ts, {iType + ' opened': 0, iType + ' closed': count})
+ timeseries[ts] = timeseries.get(ts, makeTS(distinct))
timeseries[ts][iType + ' opened'] = timeseries[ts].get(iType + ' opened', 0) + count
@@ -226,10 +235,8 @@ def run(API, environ, indata, session):
for bucket in res['aggregations']['commits']['buckets']:
ts = int(bucket['key'] / 1000)
count = bucket['doc_count']
- if not ts in timeseries:
- timeseries[ts] = {iType + ' opened': 0, iType + ' closed': count}
- else:
- timeseries[ts][iType + ' closed'] = timeseries[ts].get(iType + ' closed', 0) + count
+ timeseries[ts] = timeseries.get(ts, makeTS(distinct))
+ timeseries[ts][iType + ' closed'] = timeseries[ts].get(iType + ' closed', 0) + count
ts = []
for k, v in timeseries.items():
--
To stop receiving notification emails like this one, please contact
['"commits@kibble.apache.org" <co...@kibble.apache.org>'].