easier to just loop the bad links
parent
b69aeaeaa8
commit
4356f02b5e
|
@ -13,41 +13,14 @@ DOAB Link Checking Problems by Publisher
|
||||||
<th>Publisher</th>
|
<th>Publisher</th>
|
||||||
<th>Number</th>
|
<th>Number</th>
|
||||||
</tr>
|
</tr>
|
||||||
{% for pub in pubs %}
|
{% for pub, numbad in pubs %}
|
||||||
<tr style="color:red">
|
<tr style="color:red">
|
||||||
<td> <a href="#{{ pub.pub | default:'*** no publisher name ***'| urlencode}}">{{ pub.pub | default:'*** no publisher name ***' }}</a> </td>
|
<td> <a href="{% url 'publisher' pub %}">{{ pub | default:'*** no publisher name ***' }}</a> </td>
|
||||||
<td> {{ pub.bad_links.count }} </td>
|
<td> {{ numbad }} </td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<h3>Problem links by publisher</h3>
|
|
||||||
<ul>
|
|
||||||
{% for pub in pubs %}
|
|
||||||
<li id={{ pub.pub | default:'*** no publisher name ***' | urlencode }}><h4>{{ pub.pub | default:'*** no publisher name ***'}}</h4>
|
|
||||||
{% for link in pub.bad_links.all %}
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<th>
|
|
||||||
<a href="{{ link.url }}">{{ link.url }}</a>
|
|
||||||
</th>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<table>
|
|
||||||
{% for check in link.recent_checks %}
|
|
||||||
<tr>
|
|
||||||
<td>{{ check.created }}:</td>
|
|
||||||
<td style="color:red">{{ check.return_code }}</td>
|
|
||||||
<td>{{ check.content_type }}</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</table>
|
|
||||||
</li>
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
</ul>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
|
@ -85,16 +85,14 @@ class ProblemPublishersView(generic.TemplateView):
|
||||||
template_name = 'probpubs.html'
|
template_name = 'probpubs.html'
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
onepub = Link.objects.filter(items=OuterRef("pk"))[:1].values('items__publisher_name')
|
probpubs = {}
|
||||||
problinks = Link.objects.exclude(
|
problinks = Link.objects.exclude(
|
||||||
recent_check__isnull=True).exclude(
|
recent_check__isnull=True).exclude(
|
||||||
recent_check__return_code__exact=200)
|
recent_check__return_code__exact=200)
|
||||||
probpubs = problinks.annotate(pub=onepub).order_by('pub')
|
for link in problinks:
|
||||||
pubs = probpubs.values('pub').distinct()
|
pub = link.items.filter(status=1).first().publisher_name
|
||||||
numlinks = probpubs.count()
|
probpubs[pub] = probpubs.get(pub, 0) + 1
|
||||||
for publisher in pubs:
|
return {'pubs': probpubs.items() }
|
||||||
publisher['bad_links'] = probpubs.filter(pub=publisher['pub'])
|
|
||||||
return {'pubs': pubs}
|
|
||||||
|
|
||||||
|
|
||||||
class PublisherView(generic.TemplateView):
|
class PublisherView(generic.TemplateView):
|
||||||
|
|
Loading…
Reference in New Issue