summaryrefslogtreecommitdiff
path: root/mirrors/utils.py
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2013-01-14 01:00:11 -0600
committerDan McGee <dan@archlinux.org>2013-01-14 01:05:54 -0600
commit6f0ae6746baea657ee6d7c21ac0813a04f825443 (patch)
treebccc596760284ed7d04e08408ec7cf73edd50485 /mirrors/utils.py
parent5b8b6991b0b9f8174f153fe4b46376451b222cc1 (diff)
Drop country column from mirror table
We now always look for this information at the URL level, not the mirror level. This simplifies quite a bit of code in and around the mirror views. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'mirrors/utils.py')
-rw-r--r--mirrors/utils.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/mirrors/utils.py b/mirrors/utils.py
index 1d560021..3ab176b3 100644
--- a/mirrors/utils.py
+++ b/mirrors/utils.py
@@ -115,7 +115,7 @@ def get_mirror_errors(cutoff=DEFAULT_CUTOFF, mirror_ids=None):
is_success=False, check_time__gte=cutoff_time,
url__mirror__active=True, url__mirror__public=True).values(
'url__url', 'url__country', 'url__protocol__protocol',
- 'url__mirror__country', 'url__mirror__tier', 'error').annotate(
+ 'url__mirror__tier', 'error').annotate(
error_count=Count('error'), last_occurred=Max('check_time')
).order_by('-last_occurred', '-error_count')
@@ -124,8 +124,7 @@ def get_mirror_errors(cutoff=DEFAULT_CUTOFF, mirror_ids=None):
errors = list(errors)
for err in errors:
- ctry_code = err['url__country'] or err['url__mirror__country']
- err['country'] = Country(ctry_code)
+ err['country'] = Country(err['url__country'])
return errors
@@ -152,7 +151,7 @@ def get_mirror_url_for_download(cutoff=DEFAULT_CUTOFF):
mirror_urls = MirrorUrl.objects.filter(
mirror__public=True, mirror__active=True, protocol__default=True)
# look first for a country-agnostic URL, then fall back to any HTTP URL
- filtered_urls = mirror_urls.filter(mirror__country='')[:1]
+ filtered_urls = mirror_urls.filter(country='')[:1]
if not filtered_urls:
filtered_urls = mirror_urls[:1]
if not filtered_urls: