add result summaries
parent
62e00928f4
commit
7d1c1f4e80
|
@ -4,15 +4,30 @@
|
|||
</head>
|
||||
<body>
|
||||
<h2>
|
||||
Linkchecking for
|
||||
{{provider.provider}} ({{provider.link_count}})
|
||||
Link Checking for
|
||||
{{provider.provider}} ({{provider.link_count}} links)
|
||||
</h2>
|
||||
<h3>Summary</h3>
|
||||
<table>
|
||||
<tr>
|
||||
<th>HTTP Code</th>
|
||||
<th>number</th>
|
||||
</tr>
|
||||
{% for code in codes %}
|
||||
<tr {% if code.recent_check__return_code != 200 %} style="color:red"{% endif %}>
|
||||
<td> {{ code.recent_check__return_code }} </td>
|
||||
<td> {{ code.count }} </td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
||||
<h3>Checked links</h3>
|
||||
<ul>
|
||||
{% for link in links %}
|
||||
<li>
|
||||
<a href="{{link.url}}">{{link.url}}</a>
|
||||
<table>
|
||||
{% for check in link.checks.all %}
|
||||
{% for check in link.recent_checks %}
|
||||
<tr>
|
||||
<td>{{ check.created }}</td>
|
||||
<td {% if check.return_code != 200 %} style="color:red"{% endif %}>{{ check.return_code }}</td>
|
||||
|
|
|
@ -5,8 +5,24 @@
|
|||
<body>
|
||||
<h2>
|
||||
DOAB Linkchecking for
|
||||
{{ publisher.publisher }} ({{ items.count }} records)
|
||||
{{ publisher.publisher }} ({{ publisher.item_count|default:0 }} records)
|
||||
</h2>
|
||||
|
||||
<h3>Link checking summary</h3>
|
||||
<table>
|
||||
<tr>
|
||||
<th>HTTP Code</th>
|
||||
<th>number</th>
|
||||
</tr>
|
||||
{% for code in codes %}
|
||||
<tr {% if code.links__recent_check__return_code != 200 %} style="color:red"{% endif %}>
|
||||
<td> {{ code.links__recent_check__return_code }} </td>
|
||||
<td> {{ code.count }} </td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
||||
<h3>Items with checked links</h3>
|
||||
<ul>
|
||||
{% for item in items %}
|
||||
<li>
|
||||
|
@ -20,9 +36,9 @@ DOAB Linkchecking for
|
|||
<tr>
|
||||
<td>
|
||||
<table>
|
||||
{% for check in link.checks.all %}
|
||||
{% for check in link.recent_checks %}
|
||||
<tr {% if check.return_code != 200 %} style="color:red"{% endif %}>
|
||||
<td>{{ check.created }}</td>
|
||||
<td>{{ check.created }}:</td>
|
||||
<td>{{ check.return_code }}</td>
|
||||
<td>{{ check.content_type }}</td>
|
||||
</tr>
|
||||
|
@ -33,6 +49,8 @@ DOAB Linkchecking for
|
|||
{% endfor %}
|
||||
</table>
|
||||
</li>
|
||||
{% empty %}
|
||||
None of the active links for {{ publisher.publisher }} have been checked.
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</body>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
"""doab_check views
|
||||
"""
|
||||
|
||||
from django.db.models import Count
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.shortcuts import get_object_or_404, render
|
||||
from django.urls import reverse
|
||||
|
@ -9,6 +10,30 @@ from django.views import generic
|
|||
from .models import Item, Link
|
||||
|
||||
|
||||
class HomepageView(generic.TemplateView):
|
||||
template_name = 'index.html'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
codes = Link.objects.filter(recent_check__isnull=False).order_by('-recent_check__return_code').values(
|
||||
'recent_check__return_code').distinct()
|
||||
for code in codes:
|
||||
code['count'] = Link.objects.filter(
|
||||
recent_check__return_code=code['recent_check__return_code'],
|
||||
).distinct().count()
|
||||
return {'codes': codes}
|
||||
|
||||
|
||||
class ProblemsView(generic.TemplateView):
|
||||
template_name = 'problems.html'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
problems = Link.objects.exclude(
|
||||
recent_check__return_code__exact=200).exclude(recent_check__isnull=True
|
||||
).order_by(
|
||||
'-recent_check__return_code', 'provider')
|
||||
return {'problem_list': problems}
|
||||
|
||||
|
||||
class ProvidersView(generic.TemplateView):
|
||||
template_name = 'providers.html'
|
||||
|
||||
|
@ -25,10 +50,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)
|
||||
provider_links = Link.objects.filter(provider=prov, live=True, recent_check__isnull=False)
|
||||
provider['link_count'] = provider_links.count()
|
||||
codes = provider_links.order_by('-recent_check__return_code').values(
|
||||
'recent_check__return_code').distinct()
|
||||
for code in codes:
|
||||
code['count'] = provider_links.filter(
|
||||
recent_check__return_code=code['recent_check__return_code'],
|
||||
).distinct().count()
|
||||
|
||||
return {'provider': provider, 'links': provider_links}
|
||||
return {'provider': provider, 'links': provider_links, 'codes': codes}
|
||||
|
||||
class PublishersView(generic.TemplateView):
|
||||
template_name = 'publishers.html'
|
||||
|
@ -46,12 +77,21 @@ class PublisherView(generic.TemplateView):
|
|||
def get_context_data(self, **kwargs):
|
||||
pub = kwargs['publisher']
|
||||
publisher = {'publisher': pub}
|
||||
publisher_items = Item.objects.filter(publisher_name=pub, status=1)
|
||||
publisher['link_count'] = publisher_items.count()
|
||||
if pub == '*** no publisher name ***':
|
||||
pub = ''
|
||||
publisher_items = Item.objects.filter(
|
||||
publisher_name=pub, status=1,
|
||||
)
|
||||
publisher['item_count'] = publisher_items.count()
|
||||
publisher_items = publisher_items.filter(links__recent_check__isnull=False).distinct()
|
||||
|
||||
return {'publisher': publisher, 'items': publisher_items}
|
||||
codes = publisher_items.order_by('-links__recent_check__return_code').values(
|
||||
'links__recent_check__return_code').distinct()
|
||||
for code in codes:
|
||||
code['count'] = Link.objects.filter(live=True,
|
||||
recent_check__return_code=code['links__recent_check__return_code'],
|
||||
items__publisher_name=pub).distinct().count()
|
||||
|
||||
|
||||
|
||||
return {'publisher': publisher, 'items': publisher_items, 'codes': codes}
|
||||
|
|
Loading…
Reference in New Issue