Improve stat deltas, division by zero
This commit is contained in:
parent
937a545b23
commit
1762dc5035
@ -29,10 +29,10 @@
|
||||
<p class="label">
|
||||
{% if stats.bounce_rate_pct != None %}
|
||||
{{stats.bounce_rate_pct|floatformat:"-1"}}%
|
||||
{% compare stats.compare.bounce_rate_pct stats.bounce_rate_pct "DOWN" %}
|
||||
{% else %}
|
||||
?
|
||||
{% endif %}
|
||||
{% compare stats.compare.bounce_rate_pct stats.bounce_rate_pct "DOWN" %}
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
@ -40,10 +40,10 @@
|
||||
<p class="label">
|
||||
{% if stats.avg_session_duration != None %}
|
||||
{{stats.avg_session_duration|naturaldelta}}
|
||||
{% compare stats.compare.avg_session_duration stats.avg_session_duration "UP" %}
|
||||
{% else %}
|
||||
?
|
||||
{% endif %}
|
||||
{% compare stats.compare.avg_session_duration stats.avg_session_duration "UP" %}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -36,12 +36,12 @@
|
||||
<p class="heading">
|
||||
{% if stats.avg_load_time %}
|
||||
{{stats.avg_load_time|floatformat:"0"}}ms
|
||||
<div>
|
||||
{% compare stats.compare.avg_load_time stats.avg_load_time "DOWN" classes=classes good_classes=good_classes bad_classes=bad_classes neutral_classes=neutral_classes %}
|
||||
</div>
|
||||
{% else %}
|
||||
?
|
||||
{% endif %}
|
||||
<div>
|
||||
{% compare stats.compare.avg_load_time stats.avg_load_time "DOWN" classes=classes good_classes=good_classes bad_classes=bad_classes neutral_classes=neutral_classes %}
|
||||
</div>
|
||||
</p>
|
||||
</article>
|
||||
<article class="">
|
||||
@ -49,12 +49,12 @@
|
||||
<p class="heading">
|
||||
{% if stats.bounce_rate_pct %}
|
||||
{{stats.bounce_rate_pct|floatformat:"-1"}}%
|
||||
<div>
|
||||
{% compare stats.compare.bounce_rate_pct stats.bounce_rate_pct "DOWN" classes=classes good_classes=good_classes bad_classes=bad_classes neutral_classes=neutral_classes %}
|
||||
</div>
|
||||
{% else %}
|
||||
?
|
||||
{% endif %}
|
||||
<div>
|
||||
{% compare stats.compare.bounce_rate_pct stats.bounce_rate_pct "DOWN" classes=classes good_classes=good_classes bad_classes=bad_classes neutral_classes=neutral_classes %}
|
||||
</div>
|
||||
</p>
|
||||
</article>
|
||||
<article class="">
|
||||
@ -62,12 +62,12 @@
|
||||
<p class="heading">
|
||||
{% if stats.avg_session_duration %}
|
||||
{{stats.avg_session_duration|naturaldelta}}
|
||||
<div>
|
||||
{% compare stats.compare.avg_session_duration stats.avg_session_duration "UP" classes=classes good_classes=good_classes bad_classes=bad_classes neutral_classes=neutral_classes %}
|
||||
</div>
|
||||
{% else %}
|
||||
?
|
||||
{% endif %}
|
||||
<div>
|
||||
{% compare stats.compare.avg_session_duration stats.avg_session_duration "UP" classes=classes good_classes=good_classes bad_classes=bad_classes neutral_classes=neutral_classes %}
|
||||
</div>
|
||||
</p>
|
||||
</article>
|
||||
<article class="">
|
||||
@ -75,12 +75,12 @@
|
||||
<p class="heading">
|
||||
{% if stats.avg_hits_per_session %}
|
||||
{{stats.avg_hits_per_session|floatformat:"-1"}}
|
||||
<div>
|
||||
{% compare stats.compare.avg_hits_per_session stats.avg_hits_per_session "UP" classes=classes good_classes=good_classes bad_classes=bad_classes neutral_classes=neutral_classes %}
|
||||
</div>
|
||||
{% else %}
|
||||
?
|
||||
{% endif %}
|
||||
<div>
|
||||
{% compare stats.compare.avg_hits_per_session stats.avg_hits_per_session "UP" classes=classes good_classes=good_classes bad_classes=bad_classes neutral_classes=neutral_classes %}
|
||||
</div>
|
||||
</p>
|
||||
</article>
|
||||
{% endwith %}
|
||||
|
@ -67,12 +67,14 @@ def percent_change_display(start, end):
|
||||
if start == None or end == None:
|
||||
return SafeString("Δ n/a")
|
||||
if start == end:
|
||||
direction = ""
|
||||
direction = "Δ "
|
||||
else:
|
||||
direction = "↑ " if end > start else "↓ "
|
||||
|
||||
if start == 0 and end != 0:
|
||||
pct_change = "100%"
|
||||
elif start == 0:
|
||||
pct_change = "0%"
|
||||
else:
|
||||
change = int(round(100 * abs(end - start) / start))
|
||||
if change > 999:
|
||||
|
Loading…
Reference in New Issue
Block a user