main: switch details_link to a simple tag

An inclusion_tag renders a template on every request, for the glibc page
this meant calling Template.render() 7529 times(!) and loading ~ 5
seconds on my AMD Ryzen 7 5700X 8 Core. With this change we now do 3629
Template.render calls in 500 ms.
This commit is contained in:
Jelle van der Waa 2024-07-20 16:54:10 +02:00 committed by Jelle van der Waa
parent d01193a2a9
commit 8d07c92255
2 changed files with 4 additions and 3 deletions

View File

@ -3,6 +3,7 @@
from django import template
from django.conf import settings
from django.utils.html import format_html
from main.templatetags import pgp
from main.utils import gitlab_project_name_to_path
@ -18,9 +19,10 @@ def link_encode(url, query):
return "%s?%s" % (url, data)
@register.inclusion_tag('packages/details_link.html')
@register.simple_tag
def details_link(pkg):
return {'pkg': pkg}
link = '<a href="%s" title="View package details for %s">%s</a>'
return format_html(link % (pkg.get_absolute_url(), pkg.pkgname, pkg.pkgname))
@register.simple_tag

View File

@ -1 +0,0 @@
<a href="{{ pkg.get_absolute_url }}" title="View package details for {{ pkg.pkgname }}">{{ pkg.pkgname }}</a>