optimize provider views
parent
8836372d19
commit
0a3a1ca6d4
|
@ -22,7 +22,7 @@ Link Checking for
|
||||||
{% for code in codes %}
|
{% for code in codes %}
|
||||||
<tr {% if code.recent_check__return_code != 200 %} style="color:red"{% endif %}>
|
<tr {% if code.recent_check__return_code != 200 %} style="color:red"{% endif %}>
|
||||||
<td> {{ code.recent_check__return_code }} </td>
|
<td> {{ code.recent_check__return_code }} </td>
|
||||||
<td> <a href="#code{{ code.recent_check__return_code }}">{{ code.count }}</a>
|
<td> <a href="#code{{ code.recent_check__return_code }}">{{ code.recent_check__return_code__count }}</a>
|
||||||
<td><a href="{% url 'fixing' %}#{{ code.recent_check__return_code }}">how to fix</a></td>
|
<td><a href="{% url 'fixing' %}#{{ code.recent_check__return_code }}">how to fix</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% empty %}
|
{% empty %}
|
||||||
|
@ -36,7 +36,7 @@ Link Checking for
|
||||||
{% with code=codeobj.recent_check__return_code %}
|
{% with code=codeobj.recent_check__return_code %}
|
||||||
<h3{% if code != 200 %} style="color:red"{% endif %} id="code{{ code }}"> {{ code }}</h3>
|
<h3{% if code != 200 %} style="color:red"{% endif %} id="code{{ code }}"> {{ code }}</h3>
|
||||||
{% for link in codeobj.links %}
|
{% for link in codeobj.links %}
|
||||||
{% with title=link.items.all.0.title %}
|
{% with title=link.title %}
|
||||||
{% ifchanged title %}<div class='itemtitle'>{{ title }}</div>{% endifchanged %}
|
{% ifchanged title %}<div class='itemtitle'>{{ title }}</div>{% endifchanged %}
|
||||||
|
|
||||||
<div class='itemlink'><a href="{{ link.url }}">{{ link.url }}</a></div>
|
<div class='itemlink'><a href="{{ link.url }}">{{ link.url }}</a></div>
|
||||||
|
|
|
@ -11,10 +11,10 @@
|
||||||
<h2>
|
<h2>
|
||||||
DOAB Link Checking by Server Hostname
|
DOAB Link Checking by Server Hostname
|
||||||
</h2>
|
</h2>
|
||||||
|
<p>(number of links checked in parentheses)
|
||||||
<ul>
|
<ul>
|
||||||
{% for provider in provider_list %}
|
{% for provider in provider_list %}
|
||||||
<li><a href="{% url 'provider' provider.provider %}">{{provider.provider}}</a> ({{provider.link_count}})</li>
|
<li><a href="{% url 'provider' provider.provider %}">{{provider.provider}}</a> ({{provider.provider__count}})</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
"""doab_check views
|
"""doab_check views
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from django.db.models import Count, OuterRef, Subquery
|
from django.db.models import Count, F
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect
|
||||||
from django.shortcuts import get_object_or_404, render
|
from django.shortcuts import get_object_or_404, render
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
@ -46,9 +46,8 @@ class ProvidersView(generic.TemplateView):
|
||||||
template_name = 'providers.html'
|
template_name = 'providers.html'
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
providers = Link.objects.order_by('provider').values('provider').distinct()
|
providers = Link.objects.order_by('provider').filter(live=True, recent_check__isnull=False,
|
||||||
for provider in providers:
|
).values('provider').distinct().annotate(Count('provider'))
|
||||||
provider['link_count'] = Link.objects.filter(provider=provider['provider']).count()
|
|
||||||
return {'provider_list': providers}
|
return {'provider_list': providers}
|
||||||
|
|
||||||
|
|
||||||
|
@ -61,12 +60,11 @@ class ProviderView(generic.TemplateView):
|
||||||
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)
|
||||||
provider['link_count'] = provider_links.count()
|
provider['link_count'] = provider_links.count()
|
||||||
codes = provider_links.order_by('-recent_check__return_code').values(
|
codes = provider_links.order_by('-recent_check__return_code').values(
|
||||||
'recent_check__return_code').distinct()
|
'recent_check__return_code').distinct().annotate(Count('recent_check__return_code'))
|
||||||
for code in codes:
|
for code in codes:
|
||||||
code['links'] = provider_links.filter(live=True,
|
code['links'] = provider_links.filter(live=True,
|
||||||
recent_check__return_code=code['recent_check__return_code'],
|
recent_check__return_code=code['recent_check__return_code'],
|
||||||
).order_by('items__title')
|
).order_by('items__title').annotate(title=F('items__title'))
|
||||||
code['count'] = code['links'].count()
|
|
||||||
code['links'] = code['links'][:1000]
|
code['links'] = code['links'][:1000]
|
||||||
|
|
||||||
return {'provider': provider,
|
return {'provider': provider,
|
||||||
|
|
Loading…
Reference in New Issue