-
Notifications
You must be signed in to change notification settings - Fork 9
/
web.py
43 lines (35 loc) · 1.39 KB
/
web.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import calendar
import json
from flask import Flask, render_template
import mongoengine
import config
from models import CodeRevision
app = Flask(__name__)
db = mongoengine.connect(config.db_name)
@app.route("/")
def index():
return render_template('index.html')
@app.route("/api/stats")
def rev_stats():
test_suites = CodeRevision.MANIFESTS_REL_PATHS
revs = CodeRevision.objects(processed=True)
data = dict()
datasets = {test_suite: dict(label="Testsuite '{}'".format(test_suite),
fillColor="rgba(220,220,220,0.2)",
strokeColor="rgba(220,220,220,1)",
pointColor="rgba(220,220,220,1)",
pointStrokeColor="#fff",
pointHighlightFill="#fff",
pointHighlightStroke="rgba(220,220,220,1)",
data=[]) for test_suite in test_suites}
data['datasets'] = datasets
data['labels'] = list()
for rev in revs:
timestamp = calendar.timegm(rev.date.utctimetuple())
data['labels'].append(timestamp)
for manifest_state in rev.manifest_states:
skipped_tests = len(manifest_state.skipped_tests)
datasets[manifest_state.test_suite]['data'].append(skipped_tests)
return json.dumps(data)
if __name__ == "__main__":
app.run()