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