perf tweaks
This commit is contained in:
@@ -58,14 +58,14 @@ def CreateDBSchema(conn):
|
||||
""")
|
||||
|
||||
conn.execute("""
|
||||
CREATE TABLE IF NOT EXISTS builds(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, treeid INT, os INT, starttime INT, status INT, changeset TEXT, logfile TEXT) ENGINE MyISAM
|
||||
CREATE TABLE IF NOT EXISTS builds(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, treeid INT, os INT, starttime INT, status INT, changeset VARCHAR(255), logfile VARCHAR(255)) ENGINE MyISAM
|
||||
""")
|
||||
conn.execute("""
|
||||
CREATE INDEX builds_starttime ON builds (starttime)
|
||||
""")
|
||||
|
||||
conn.execute("""
|
||||
CREATE TABLE IF NOT EXISTS tests (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, buildid INT, name TEXT, description TEXT) ENGINE MyISAM
|
||||
CREATE TABLE IF NOT EXISTS tests (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, buildid INT, name VARCHAR(2000), description VARCHAR(5000)) ENGINE MyISAM
|
||||
""")
|
||||
conn.execute("""
|
||||
CREATE INDEX tests_name ON tests (name(255))
|
||||
|
||||
@@ -76,6 +76,9 @@ class Tests(models.Model):
|
||||
db_table = 'tests'
|
||||
|
||||
def get_most_failing_tests(tree):
|
||||
return Tests.objects.filter(build__tree__name=tree).values('name').annotate(count=models.Count('name')).order_by('-count')[:25]
|
||||
|
||||
def get_time_failing_tests(tree):
|
||||
return Tests.objects.filter(build__tree__name=tree).values('name').annotate(count=models.Count('name')).order_by('-count')
|
||||
|
||||
def get_fails_in_timerange(self,tree):
|
||||
@@ -97,7 +100,7 @@ def get_fails_in_timerange(self,tree):
|
||||
'h': 3600}[m.group(2)]
|
||||
# Set current time to beginning of requested timespan ending now.
|
||||
curtime = endtime - timespan
|
||||
qs = get_most_failing_tests(tree)
|
||||
qs = get_time_failing_tests(tree)
|
||||
return qs.filter(build__starttime__gt=curtime)
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ from django.http import HttpResponse
|
||||
import json
|
||||
|
||||
def latest(request,tree='Firefox'):
|
||||
failures = get_list_or_404(Tests.objects.filter(build__tree__name=tree).order_by('-build__starttime'))[:10]
|
||||
failures = get_list_or_404(Tests.objects.filter(build__tree__name=tree).order_by('-build__starttime')[:20])
|
||||
if request.GET.has_key('json'):
|
||||
jtext = [{"Test_name":f.name, "Build_status":f.build.status, "Logfile": f.build.tinderbox_link(),"Changeset":f.build.json_changeset_link() , "Failure_description":f.description} for f in failures]
|
||||
return HttpResponse(json.dumps(jtext))
|
||||
@@ -13,7 +13,7 @@ def latest(request,tree='Firefox'):
|
||||
return render_to_response('viewer/latest.html', {'failures': failures, 'tree' : tree})
|
||||
|
||||
def index(request,tree='Firefox'):
|
||||
failures = get_list_or_404(Tests.objects.filter(build__tree__name=tree).order_by('-build__starttime')[:10])
|
||||
failures = get_list_or_404(Tests.objects.filter(build__tree__name=tree).order_by('-build__starttime')[:20])
|
||||
return render_to_response('viewer/index.html', {'failures': failures, 'tree' : tree})
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ def test(request,tree='Firefox'):
|
||||
return render_to_response('viewer/test.html', {'test': request.GET['name'], 'failures': failures, 'tree' : tree})
|
||||
|
||||
def topfails(request,tree='Firefox'):
|
||||
failures = get_most_failing_tests(tree)[:25]
|
||||
failures = get_most_failing_tests(tree)
|
||||
if request.GET.has_key('json'):
|
||||
jtext = list(failures)
|
||||
return HttpResponse(json.dumps(jtext))
|
||||
|
||||
Reference in New Issue
Block a user