From eb7172cd4d9d7af690b2be06e3f925d3023be71c Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sat, 8 Nov 2014 13:43:59 -0600 Subject: Convert some of URL details to Jinja2 Anytime we have a loop with >100 items, the Django template engine begins to be the bottleneck. This one is relatively straightforward to convert, and sets the stage for converting the mirror status page as well. Signed-off-by: Dan McGee --- templates/mirrors/url_details.html | 29 +-------------------------- templates/mirrors/url_details_logs.html.jinja | 28 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 28 deletions(-) create mode 100644 templates/mirrors/url_details_logs.html.jinja (limited to 'templates/mirrors') diff --git a/templates/mirrors/url_details.html b/templates/mirrors/url_details.html index 557a1b79..8b7646b8 100644 --- a/templates/mirrors/url_details.html +++ b/templates/mirrors/url_details.html @@ -1,5 +1,4 @@ {% extends "base.html" %} -{% load cycle from future %} {% load static from staticfiles %} {% load mirror_status %} {% load flags %} @@ -57,34 +56,8 @@ {% endif %} -

Check Logs

+ {% include "mirrors/url_details_logs.html.jinja" %} - - - - - - - - - - - - - - - {% for log in logs %} - - - - - - - - - {% endfor %} - -
Check TimeCheck LocationCheck IPLast SyncDelay (hh:mm)Duration (s)Success?Error Message
{{ log.check_time|date:'Y-m-d H:i' }}{% country_flag log.location.country %}{{ log.location.country.name }}{{ log.location.source_ip }}{{ log.last_sync|date:'Y-m-d H:i' }}{{ log.delay|duration }}{{ log.duration|floatvalue }}{{ log.is_success|yesno|capfirst }}{{ log.error|linebreaksbr }}
{% endblock %} diff --git a/templates/mirrors/url_details_logs.html.jinja b/templates/mirrors/url_details_logs.html.jinja new file mode 100644 index 00000000..8f7c5644 --- /dev/null +++ b/templates/mirrors/url_details_logs.html.jinja @@ -0,0 +1,28 @@ +

Check Logs

+ + + + + + + + + + + + + + + + {% for log in logs %} + + + + + + + + + {% endfor %} + +
Check TimeCheck LocationCheck IPLast SyncDelay (hh:mm)Duration (s)Success?Error Message
{{ log.check_time|date('Y-m-d H:i') }}{{ country_flag(log.location.country) }}{{ log.location.country.name }}{{ log.location.source_ip }}{{ log.last_sync|date('Y-m-d H:i') }}{{ log.delay()|duration }}{{ log.duration|floatvalue }}{{ log.is_success|yesno|capfirst }}{{ log.error|linebreaksbr }}
-- cgit v1.2.3-2-g168b From 713ab837ba59c4a7c0b60cb8e8be4b27f4520e52 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sat, 8 Nov 2014 14:00:06 -0600 Subject: Convert mirror status tables to Jinja2 Yay for way improved performance. Local testing showed render times going from 265 ms to 135 ms. Signed-off-by: Dan McGee --- templates/mirrors/error_table.html | 24 ------------------------ templates/mirrors/error_table.html.jinja | 22 ++++++++++++++++++++++ templates/mirrors/mirror_details.html | 2 +- templates/mirrors/status.html | 6 +++--- templates/mirrors/status_table.html | 30 ------------------------------ templates/mirrors/status_table.html.jinja | 28 ++++++++++++++++++++++++++++ 6 files changed, 54 insertions(+), 58 deletions(-) delete mode 100644 templates/mirrors/error_table.html create mode 100644 templates/mirrors/error_table.html.jinja delete mode 100644 templates/mirrors/status_table.html create mode 100644 templates/mirrors/status_table.html.jinja (limited to 'templates/mirrors') diff --git a/templates/mirrors/error_table.html b/templates/mirrors/error_table.html deleted file mode 100644 index cd7265af..00000000 --- a/templates/mirrors/error_table.html +++ /dev/null @@ -1,24 +0,0 @@ -{% load cycle from future %} -{% load flags mirror_status %} - - - - - - - - - - - - - {% for log in error_logs %} - - - - - - - {% endfor %} - -
Mirror URLProtocolCountryError MessageLast OccurredOccurrences (last {{ cutoff|hours }})
{{ log.url__url }}{{ log.url__protocol__protocol }}{% country_flag log.country %}{{ log.country.name }}{{ log.error|linebreaksbr }}{{ log.last_occurred|date:'Y-m-d H:i' }}{{ log.error_count }}
diff --git a/templates/mirrors/error_table.html.jinja b/templates/mirrors/error_table.html.jinja new file mode 100644 index 00000000..52f68135 --- /dev/null +++ b/templates/mirrors/error_table.html.jinja @@ -0,0 +1,22 @@ + + + + + + + + + + + + + {% for log in error_logs %} + + + + + + + {% endfor %} + +
Mirror URLProtocolCountryError MessageLast OccurredOccurrences (last {{ cutoff|hours }})
{{ log.url__url }}{{ log.url__protocol__protocol }}{{ country_flag(log.country) }}{{ log.country.name }}{{ log.error|linebreaksbr }}{{ log.last_occurred|date('Y-m-d H:i') }}{{ log.error_count }}
diff --git a/templates/mirrors/mirror_details.html b/templates/mirrors/mirror_details.html index 2ff41828..e4ae55b4 100644 --- a/templates/mirrors/mirror_details.html +++ b/templates/mirrors/mirror_details.html @@ -132,7 +132,7 @@

Error Log

- {% include "mirrors/error_table.html" %} + {% include "mirrors/error_table.html.jinja" %}
diff --git a/templates/mirrors/status.html b/templates/mirrors/status.html index 24408be7..530e3ff5 100644 --- a/templates/mirrors/status.html +++ b/templates/mirrors/status.html @@ -60,18 +60,18 @@

Out of Sync Mirrors

{% with urls=bad_urls table_id='outofsync_mirrors' %} - {% include "mirrors/status_table.html" %} + {% include "mirrors/status_table.html.jinja" %} {% endwith %}

Successfully Syncing Mirrors

{% with urls=good_urls table_id='successful_mirrors' %} - {% include "mirrors/status_table.html" %} + {% include "mirrors/status_table.html.jinja" %} {% endwith %}

Mirror Syncing Error Log

- {% include "mirrors/error_table.html" %} + {% include "mirrors/error_table.html.jinja" %}
{% endblock %} diff --git a/templates/mirrors/status_table.html b/templates/mirrors/status_table.html deleted file mode 100644 index 83538303..00000000 --- a/templates/mirrors/status_table.html +++ /dev/null @@ -1,30 +0,0 @@ -{% load cycle from future %} -{% load flags mirror_status %} - - - - - - - - - - - - - - - - {% for m_url in urls %} - - - - - - - - - - {% endfor %} - -
Mirror URLProtocolCountryCompletion %μ Delay (hh:mm)μ Duration (s)σ Duration (s)Mirror Score
{{ m_url.url }}{{ m_url.protocol }}{% country_flag m_url.country %}{{ m_url.country.name }}{{ m_url.completion_pct|percentage:1 }}{{ m_url.delay|duration|default:'unknown' }}{{ m_url.duration_avg|floatvalue:2 }}{{ m_url.duration_stddev|floatvalue:2 }}{{ m_url.score|floatvalue:1|default:'∞' }}details
diff --git a/templates/mirrors/status_table.html.jinja b/templates/mirrors/status_table.html.jinja new file mode 100644 index 00000000..598a1af0 --- /dev/null +++ b/templates/mirrors/status_table.html.jinja @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + {% for m_url in urls %} + + + + + + + + + + {% endfor %} + +
Mirror URLProtocolCountryCompletion %μ Delay (hh:mm)μ Duration (s)σ Duration (s)Mirror Score
{{ m_url.url }}{{ m_url.protocol }}{{ country_flag(m_url.country) }}{{ m_url.country.name }}{{ m_url.completion_pct|percentage(1) }}{{ m_url.delay|duration|default('unknown') }}{{ m_url.duration_avg|floatvalue(2) }}{{ m_url.duration_stddev|floatvalue(2) }}{{ m_url.score|floatvalue(1)|default('∞') }}details
-- cgit v1.2.3-2-g168b From 122273496a24c4608de776978b1b449d9c6cde09 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sat, 8 Nov 2014 14:04:31 -0600 Subject: Make delay a property, not a function And re-indent the URL details log template now that we've broken it out. Signed-off-by: Dan McGee --- templates/mirrors/url_details_logs.html.jinja | 54 +++++++++++++-------------- 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'templates/mirrors') diff --git a/templates/mirrors/url_details_logs.html.jinja b/templates/mirrors/url_details_logs.html.jinja index 8f7c5644..09742f76 100644 --- a/templates/mirrors/url_details_logs.html.jinja +++ b/templates/mirrors/url_details_logs.html.jinja @@ -1,28 +1,28 @@ -

Check Logs

+

Check Logs

- - - - - - - - - - - - - - - {% for log in logs %} - - - - - - - - - {% endfor %} - -
Check TimeCheck LocationCheck IPLast SyncDelay (hh:mm)Duration (s)Success?Error Message
{{ log.check_time|date('Y-m-d H:i') }}{{ country_flag(log.location.country) }}{{ log.location.country.name }}{{ log.location.source_ip }}{{ log.last_sync|date('Y-m-d H:i') }}{{ log.delay()|duration }}{{ log.duration|floatvalue }}{{ log.is_success|yesno|capfirst }}{{ log.error|linebreaksbr }}
+ + + + + + + + + + + + + + + {% for log in logs %} + + + + + + + + + {% endfor %} + +
Check TimeCheck LocationCheck IPLast SyncDelay (hh:mm)Duration (s)Success?Error Message
{{ log.check_time|date('Y-m-d H:i') }}{{ country_flag(log.location.country) }}{{ log.location.country.name }}{{ log.location.source_ip }}{{ log.last_sync|date('Y-m-d H:i') }}{{ log.delay|duration }}{{ log.duration|floatvalue }}{{ log.is_success|yesno|capfirst }}{{ log.error|linebreaksbr }}
-- cgit v1.2.3-2-g168b From 886d2934ec672e0d4533f73e8b38248fdff9a6d5 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sat, 8 Nov 2014 14:12:32 -0600 Subject: Break out available URLs into Jinja2 template Signed-off-by: Dan McGee --- templates/mirrors/mirror_details.html | 38 +----------------------- templates/mirrors/mirror_details_urls.html.jinja | 36 ++++++++++++++++++++++ templates/mirrors/url_details.html | 2 +- templates/mirrors/url_details_logs.html.jinja | 2 -- 4 files changed, 38 insertions(+), 40 deletions(-) create mode 100644 templates/mirrors/mirror_details_urls.html.jinja (limited to 'templates/mirrors') diff --git a/templates/mirrors/mirror_details.html b/templates/mirrors/mirror_details.html index e4ae55b4..64009380 100644 --- a/templates/mirrors/mirror_details.html +++ b/templates/mirrors/mirror_details.html @@ -93,43 +93,7 @@

Available URLs

- - - - - - - - - - - - - - - - - - - - {% for m_url in urls %} - - - - - - - - - - - - - - - {% endfor %} - -
Mirror URLProtocolCountryIPv4IPv6Last SyncCompletion %μ Delay (hh:mm)μ Duration (s)σ Duration (s)ScoreDetails
{% if m_url.protocol.is_download %}{{ m_url.url }}{% else %}{{ m_url.url }}{% endif %}{{ m_url.protocol }}{% country_flag m_url.country %}{{ m_url.country.name }}{{ m_url.has_ipv4|yesno|capfirst }}{{ m_url.has_ipv6|yesno|capfirst }}{{ m_url.last_sync|date:'Y-m-d H:i'|default:'unknown' }}{{ m_url.completion_pct|percentage:1 }}{{ m_url.delay|duration|default:'unknown' }}{{ m_url.duration_avg|floatvalue:2 }}{{ m_url.duration_stddev|floatvalue:2 }}{{ m_url.score|floatvalue:1|default:'∞' }}Details
+ {% include "mirrors/mirror_details_urls.html.jinja" %}

Error Log

{% include "mirrors/error_table.html.jinja" %} diff --git a/templates/mirrors/mirror_details_urls.html.jinja b/templates/mirrors/mirror_details_urls.html.jinja new file mode 100644 index 00000000..7ab1548b --- /dev/null +++ b/templates/mirrors/mirror_details_urls.html.jinja @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + {% for m_url in urls %} + + + + + + + + + + + + + + + {% endfor %} + +
Mirror URLProtocolCountryIPv4IPv6Last SyncCompletion %μ Delay (hh:mm)μ Duration (s)σ Duration (s)ScoreDetails
{% if m_url.protocol.is_download %}{{ m_url.url }}{% else %}{{ m_url.url }}{% endif %}{{ m_url.protocol }}{{ country_flag(m_url.country) }}{{ m_url.country.name }}{{ m_url.has_ipv4|yesno|capfirst }}{{ m_url.has_ipv6|yesno|capfirst }}{{ m_url.last_sync|date('Y-m-d H:i')|default('unknown') }}{{ m_url.completion_pct|percentage(1) }}{{ m_url.delay|duration|default('unknown') }}{{ m_url.duration_avg|floatvalue(2) }}{{ m_url.duration_stddev|floatvalue(2) }}{{ m_url.score|floatvalue(1)|default('∞') }}Details
diff --git a/templates/mirrors/url_details.html b/templates/mirrors/url_details.html index 8b7646b8..b61033cd 100644 --- a/templates/mirrors/url_details.html +++ b/templates/mirrors/url_details.html @@ -56,8 +56,8 @@ {% endif %} +

Check Logs

{% include "mirrors/url_details_logs.html.jinja" %} - {% endblock %} diff --git a/templates/mirrors/url_details_logs.html.jinja b/templates/mirrors/url_details_logs.html.jinja index 09742f76..58f179d8 100644 --- a/templates/mirrors/url_details_logs.html.jinja +++ b/templates/mirrors/url_details_logs.html.jinja @@ -1,5 +1,3 @@ -

Check Logs

- -- cgit v1.2.3-2-g168b