optimize problems
parent
0a3a1ca6d4
commit
1af4b62fd0
|
@ -15,7 +15,7 @@ DOAB links with status code: {{ code | default:'0 or None' }}
|
|||
<ul>
|
||||
{% for provider in providers %}
|
||||
<li> <a href="#{{ provider.provider | urlencode }}">{{ provider.provider }}</a>:
|
||||
{{ provider.count }} problem links </li>
|
||||
{{ provider.provider__count }} problem links </li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
|
@ -25,7 +25,7 @@ DOAB links with status code: {{ code | default:'0 or None' }}
|
|||
<dd>
|
||||
<ul>
|
||||
{% for link in provider.links %}
|
||||
{% with title=link.items.all.0.title %}
|
||||
{% with title=link.title %}
|
||||
{% ifchanged title %}<div class='itemtitle'>{{ title }}</div>{% endifchanged %}
|
||||
|
||||
<div class='itemlink'><a href="{{ link.url }}">{{ link.url }}</a></div>
|
||||
|
|
|
@ -34,11 +34,12 @@ class ProblemsView(generic.TemplateView):
|
|||
code = kwargs['code']
|
||||
|
||||
problems = Link.objects.exclude(recent_check__isnull=True).filter(
|
||||
recent_check__return_code__exact=code).order_by('provider')
|
||||
providers = problems.values('provider').distinct()
|
||||
recent_check__return_code__exact=code).order_by('provider'
|
||||
).annotate(title=F('items__title'))
|
||||
providers = problems.values('provider').distinct().annotate(Count('provider'))
|
||||
for provider in providers:
|
||||
provider['links'] = problems.filter(provider=provider['provider'])
|
||||
provider['count'] = provider['links'].count()
|
||||
#provider['count'] = provider['links'].count()
|
||||
return {'code': code, 'providers': providers}
|
||||
|
||||
|
||||
|
@ -57,14 +58,16 @@ class ProviderView(generic.TemplateView):
|
|||
def get_context_data(self, **kwargs):
|
||||
prov = kwargs['provider']
|
||||
provider = {'provider': prov}
|
||||
provider_links = Link.objects.filter(provider=prov, live=True, recent_check__isnull=False)
|
||||
provider_links = Link.objects.filter(
|
||||
provider=prov, live=True, recent_check__isnull=False
|
||||
).annotate(title=F('items__title'))
|
||||
provider['link_count'] = provider_links.count()
|
||||
codes = provider_links.order_by('-recent_check__return_code').values(
|
||||
'recent_check__return_code').distinct().annotate(Count('recent_check__return_code'))
|
||||
for code in codes:
|
||||
code['links'] = provider_links.filter(live=True,
|
||||
recent_check__return_code=code['recent_check__return_code'],
|
||||
).order_by('items__title').annotate(title=F('items__title'))
|
||||
).order_by('items__title')
|
||||
code['links'] = code['links'][:1000]
|
||||
|
||||
return {'provider': provider,
|
||||
|
|
Loading…
Reference in New Issue