Compare commits

...

2 Commits

Author SHA1 Message Date
R. Miles McCain
2f778dc4b4 Bump version to v0.7.3 2021-01-11 12:12:15 -05:00
R. Miles McCain
e0c165313b Add fallback to percent_change_display (fixes #89) 2021-01-11 12:11:27 -05:00
2 changed files with 21 additions and 18 deletions

View File

@@ -61,25 +61,28 @@ def relative_stat_tone(
@register.simple_tag
def percent_change_display(start, end):
if start == None or end == None:
return SafeString("Δ n/a")
if start == end:
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) / max(start, 1)))
if change > 999:
return "> 999%"
try:
if start == None or end == None:
return SafeString("Δ n/a")
if start == end:
direction = "Δ "
else:
pct_change = str(change) + "%"
direction = "↑ " if end > start else "↓ "
return SafeString(direction + pct_change)
if start == 0 and end != 0:
pct_change = "100%"
elif start == 0:
pct_change = "0%"
else:
change = int(round(100 * abs(end - start) / max(start, 1)))
if change > 999:
return "> 999%"
else:
pct_change = str(change) + "%"
return SafeString(direction + pct_change)
except: # TODO: filter for specific issues
return SafeString("Δ ?")
@register.inclusion_tag("dashboard/includes/sidebar_footer.html")

View File

@@ -18,7 +18,7 @@ import urllib.parse as urlparse
from django.contrib.messages import constants as messages
# Increment on new releases
VERSION = "v0.7.2"
VERSION = "v0.7.3"
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))