From f94bdb218e7a6ea0cb74e8672eb6d05c049b582e Mon Sep 17 00:00:00 2001 From: Eddy Ernesto del Valle Pino Date: Wed, 8 Oct 2014 14:33:42 -0400 Subject: [PATCH 1/4] Code formating. --- profiler/urls.py | 3 +-- profiler/views.py | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/profiler/urls.py b/profiler/urls.py index 07f3b7f..e73b0f9 100644 --- a/profiler/urls.py +++ b/profiler/urls.py @@ -6,5 +6,4 @@ url(r'^by_view/$', 'stats_by_view', name='profiler_stats_by_view'), url(r'^code/$', 'python_stats', name='profiler_python_stats'), url(r'^reset/$', 'reset', name='profiler_reset'), - ) - +) diff --git a/profiler/views.py b/profiler/views.py index 150f3ba..2b11ed7 100644 --- a/profiler/views.py +++ b/profiler/views.py @@ -23,23 +23,23 @@ def stats_by_view(request): grouped = {} for r in stats: if r['view'] not in grouped: - grouped[r['view']] = {'queries' : [], + grouped[r['view']] = {'queries' : [], 'count' : 0, 'time' : 0, 'average_time' : 0} grouped[r['view']]['queries'].append(r) grouped[r['view']]['count'] += r['count'] grouped[r['view']]['time'] += r['time'] - r['average_time'] = r['time'] / r['count'] + r['average_time'] = r['time'] / r['count'] grouped[r['view']]['average_time'] += r['average_time'] - + maxtime = 0 for r in stats: if r['average_time'] > maxtime: maxtime = r['average_time'] for r in stats: r['normtime'] = (0.0+r['average_time'])/maxtime - + return render_to_response('profiler/by_view.html', {'queries' : grouped, 'stats' :simplejson.dumps(stats)}, From 6d6b14da0dca96b45348fcdd37442126a4a3e19b Mon Sep 17 00:00:00 2001 From: Eddy Ernesto del Valle Pino Date: Wed, 8 Oct 2014 14:34:04 -0400 Subject: [PATCH 2/4] Remove unused imports. --- profiler/views.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/profiler/views.py b/profiler/views.py index 2b11ed7..af6b8d6 100644 --- a/profiler/views.py +++ b/profiler/views.py @@ -1,7 +1,6 @@ -from django.http import HttpResponse, HttpResponseRedirect +from django.http import HttpResponseRedirect from django.shortcuts import render_to_response from django.template.context import RequestContext -from django.core.cache import cache from django.contrib.auth.decorators import user_passes_test from django.core.urlresolvers import reverse from django.utils import simplejson From 899eb496678e18b58ef6224ddfdbdda7a29584cb Mon Sep 17 00:00:00 2001 From: Eddy Ernesto del Valle Pino Date: Wed, 8 Oct 2014 14:34:18 -0400 Subject: [PATCH 3/4] Use json insted of simplejson. --- profiler/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/profiler/views.py b/profiler/views.py index af6b8d6..7420d0a 100644 --- a/profiler/views.py +++ b/profiler/views.py @@ -1,9 +1,9 @@ +import json from django.http import HttpResponseRedirect from django.shortcuts import render_to_response from django.template.context import RequestContext from django.contrib.auth.decorators import user_passes_test from django.core.urlresolvers import reverse -from django.utils import simplejson from aggregate.client import get_client @@ -41,7 +41,7 @@ def stats_by_view(request): return render_to_response('profiler/by_view.html', {'queries' : grouped, - 'stats' :simplejson.dumps(stats)}, + 'stats' :json.dumps(stats)}, context_instance=RequestContext(request)) @user_passes_test(lambda u:u.is_superuser) From 2bcb504b1b15654a4a919cbf62c7ec5502bd58ba Mon Sep 17 00:00:00 2001 From: Eddy Ernesto del Valle Pino Date: Wed, 8 Oct 2014 14:34:33 -0400 Subject: [PATCH 4/4] Make imports in urls work again. --- profiler/urls.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/profiler/urls.py b/profiler/urls.py index e73b0f9..2c58790 100644 --- a/profiler/urls.py +++ b/profiler/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import * +from django.conf.urls import url, patterns urlpatterns = patterns( 'profiler.views',