Permalink
Browse files

Average results for each revision with the same platform/test/branch.

  • Loading branch information...
markrcote committed May 1, 2012
1 parent b48f8f4 commit 32b578592a29116c6326b739e89150e5cf4467ad
Showing with 14 additions and 1 deletion.
  1. +14 −1 peptest/server/handlers.py
View
@@ -2,6 +2,7 @@
import datetime
import templeton.handlers
import web
+from collections import defaultdict
class DefaultConfigParser(ConfigParser.ConfigParser):
@@ -57,14 +58,26 @@ def GET(self):
if wheres:
query += ' where %s' % ' and '.join(wheres)
results = db.query(query, vars=vars)
- response = []
+
+ # average results for each revision
+ # all results are for just one test/platform/branch, so we can keep
+ # this simple
+ by_revision = defaultdict(list)
for r in results:
d = {}
for k, v in r.iteritems():
if isinstance(v, datetime.datetime):
d[k] = v.isoformat()
else:
d[k] = v
+ by_revision[d['revision']].append(d)
+
+ response = []
+ for results in by_revision.values():
+ # copy first element to preserve all the other metadata
+ d = results[0].copy()
+ d['metric'] = float(sum([x['metric'] for x in results])) / len(results)
+ d['pass'] = all([x['pass'] for x in results])
response.append(d)
return response

0 comments on commit 32b5785

Please sign in to comment.