summaryrefslogtreecommitdiff
path: root/mirrors
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-07-08 20:38:01 -0500
committerDan McGee <dan@archlinux.org>2012-07-08 21:08:04 -0500
commit0f3c894e7a0f573fa0198459150f387c3a7f23ae (patch)
treef89078b9dd023ea2ee9e86caaf0358d12cd1adbf /mirrors
parent26a00cadcebc0b37775954d261ec73f927ceca12 (diff)
Don't include StdDev on sqlite3 mirror status query
Because this function isn't shipped by default, it makes more sense to just omit it completely from the query we do to build the tables on this page when in development. Substitute 0.0 for the value so the rest of the calculations and display work as expected. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'mirrors')
-rw-r--r--mirrors/utils.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/mirrors/utils.py b/mirrors/utils.py
index 2014411d..9aa8e0f5 100644
--- a/mirrors/utils.py
+++ b/mirrors/utils.py
@@ -3,7 +3,7 @@ from datetime import timedelta
from django.db.models import Avg, Count, Max, Min, StdDev
from django_countries.fields import Country
-from main.utils import cache_function, utc_now
+from main.utils import cache_function, utc_now, database_vendor
from .models import MirrorLog, MirrorProtocol, MirrorUrl
@@ -40,8 +40,11 @@ def get_mirror_statuses(cutoff=default_cutoff):
success_count=Count('logs__duration'),
last_sync=Max('logs__last_sync'),
last_check=Max('logs__check_time'),
- duration_avg=Avg('logs__duration'),
- duration_stddev=StdDev('logs__duration'))
+ duration_avg=Avg('logs__duration'))
+
+ vendor = database_vendor(MirrorUrl)
+ if vendor != 'sqlite':
+ urls.annotate(duration_stddev=StdDev('logs__duration'))
# The Django ORM makes it really hard to get actual average delay in the
# above query, so run a seperate query for it and we will process the
@@ -70,6 +73,9 @@ def get_mirror_statuses(cutoff=default_cutoff):
check_frequency = None
for url in urls:
+ # fake the standard deviation for local testing setups
+ if vendor == 'sqlite':
+ setattr(url, 'duration_stddev', 0.0)
annotate_url(url, delays)
return {