optimized publisher list

main
eric 2023-09-06 15:25:36 -04:00
parent 13f30b7de8
commit 8836372d19
2 changed files with 6 additions and 9 deletions

View File

@ -11,13 +11,12 @@
<h2> <h2>
DOAB Linkchecking by Publisher DOAB Linkchecking by Publisher
</h2> </h2>
<p>(number of books in parentheses)
<ul> <ul>
{% for publisher in publisher_list %} {% for publisher in publisher_list %}
<li><a href="{% url 'publisher' publisher.publisher_name|default:'*** no publisher name ***' %}"> <li><a href="{% url 'publisher' publisher.publisher_name|default:'*** no publisher name ***' %}">
{% if publisher.publisher_name %}{{publisher.publisher_name}} {{ publisher.publisher_name|default:'*** no publisher name ***' }}
{% else %}*** no publisher name *** </a> ({{ publisher.publisher_name__count }})</li>
{% endif %}
</a> ({{publisher.item_count}})</li>
{% endfor %} {% endfor %}
</ul> </ul>
</div> </div>

View File

@ -87,10 +87,9 @@ class PublishersView(generic.TemplateView):
template_name = 'publishers.html' template_name = 'publishers.html'
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
publishers = Item.objects.order_by('publisher_name').values('publisher_name').distinct() items = Item.objects.filter(status=1)
for publisher in publishers: publishers = items.order_by('publisher_name').values(
publisher['item_count'] = Item.objects.filter( 'publisher_name').distinct().annotate(Count('publisher_name'))
publisher_name=publisher['publisher_name'], status=1).count()
return {'publisher_list': publishers} return {'publisher_list': publishers}
@ -98,7 +97,6 @@ class ProblemPublishersView(generic.TemplateView):
template_name = 'probpubs.html' template_name = 'probpubs.html'
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
probpubs = {}
problinks = Link.objects.filter(live=True, recent_check__isnull=False).exclude( problinks = Link.objects.filter(live=True, recent_check__isnull=False).exclude(
recent_check__return_code__exact=200) recent_check__return_code__exact=200)
pubnames = problinks.order_by('items__publisher_name').values( pubnames = problinks.order_by('items__publisher_name').values(