added some stats to homepage, add number grouping

main
eric 2023-09-07 17:10:31 -04:00
parent faf217aa44
commit 5a0a602fed
2 changed files with 13 additions and 7 deletions

View File

@ -17,7 +17,7 @@ Welcome to DOAB Check!
<img style='height:5em; padding:1em; margin-bottom: 1em' src='{% static "doab.png" %}' alt='DOAB logo'>
</p
><p>
DOAB Check is a collaboration between the Free Ebook Foundation and the Directory of Open Access Books. It checks each the links in DOAB about once a month, looking for any links that are broken or misconfigured.
DOAB Check is a collaboration between the Free Ebook Foundation and the Directory of Open Access Books. It checks each the links in DOAB about once a month, looking for any links that are broken or misconfigured.
</p>
<p>
We've grouped the links by the publisher's name and by the server url to make it easier for publishers to see whether links they've entered into the DOAB database are working as expected.
@ -46,14 +46,14 @@ When a link is checked we record the status code and content type returned by th
<li><a href="{% url 'fixing' %}#code404">"404"</a> means the link is broken - the resource is not found.
<li><a href="{% url 'fixing' %}#code408">"408"</a> means the website didn't respond in a reasonable time.
<li><a href="{% url 'fixing' %}#code500">"500"</a> means something has gone wrong at the website server.
<li><a href="{% url 'fixing' %}#code502">"502"</a> means is a gateway error. Some websites use load balancers or content distribution networks; if these gateways have a problem connecting with the source website, they send a 502 response.
<li><a href="{% url 'fixing' %}#code502">"502"</a> is a gateway error. Some websites use load balancers or content distribution networks; if these gateways have a problem connecting with the source website, they send a 502 response.
<li><a href="{% url 'fixing' %}#code503">"503"</a> means that a website couldnt be reached. This could happen because the server was too busy, under maintenance, or something else. Amazon's robot blocker returns 503 codes, so these must be checked manually.
<li><a href="{% url 'fixing' %}#code504">"504"</a> indicates that the server, while acting as a gateway or proxy did not get a response in time from an upstream server.
<li><a href="{% url 'fixing' %}#code511">"511"</a> indicates a problem with the security of the connection - most often an incomplete certificate.
<li><a href="{% url 'fixing' %}#code0">"None" or "0"</a> means something has gone terribly wrong. Possibly a bug in the checker or a malformed url.
</ul>
<p> {{ num_checked }} links have been checked. <p>
<p> <b>{{ num_checked|floatformat:"g" }}</b> links are being checked. Of the <b>{{ num_items|floatformat:"g" }}</b> books and book chapters in DOAB, <b>{{ num_bad_items|floatformat:"g" }}</b> have problems. </p>
<table id="codes">
<tr>
<th>HTTP code</th>
@ -63,8 +63,8 @@ When a link is checked we record the status code and content type returned by th
{% for code in codes %}
<tr {% if code.recent_check__return_code != 200 %} style="color:red"{% endif %}>
<td> {{ code.recent_check__return_code }} </td>
<td>{% if code.recent_check__return_code != 200 %}<a href="{% url 'problems' code.recent_check__return_code %}"> {{ code.count }} </a>
{% else %} {{ code.count }} {% endif %}</td>
<td>{% if code.recent_check__return_code != 200 %}<a href="{% url 'problems' code.recent_check__return_code %}"> {{ code.count|floatformat:"g" }} </a>
{% else %} {{ code.count|floatformat:"g" }} {% endif %}</td>
<td> {{ code.percent }} </td>
</tr>
{% endfor %}

View File

@ -15,16 +15,22 @@ class HomepageView(generic.TemplateView):
def get_context_data(self, **kwargs):
active_links = Link.objects.filter(recent_check__isnull=False).only(
'recent_check').order_by('-recent_check__return_code').distinct()
'recent_check').order_by('-recent_check__return_code')
codes = active_links.values(
'recent_check__return_code').distinct()
num_checked = active_links.count()
items = Item.objects.filter(status=1)
num_items = items.count()
num_bad_items = active_links.exclude(recent_check__return_code=200).values('items'
).distinct().count()
for code in codes:
code['count'] = active_links.filter(
recent_check__return_code=code['recent_check__return_code'],
).count()
code['percent'] = '{:.2%}'.format(code['count'] / num_checked)
return {'num_checked': num_checked, 'codes': codes}
return {'num_checked': num_checked, 'codes': codes,
'num_items': num_items, 'num_bad_items': num_bad_items}
class ProblemsView(generic.TemplateView):