From 07c35ec40bd0eff0a7335e1ec684067f4c81c394 Mon Sep 17 00:00:00 2001 From: Sadra Date: Mon, 22 Aug 2022 20:14:46 +0430 Subject: [PATCH] "plus" symbol misplace fixed --- snippet/templatetags/millify.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/snippet/templatetags/millify.py b/snippet/templatetags/millify.py index f5a12e6..5f5ce2e 100644 --- a/snippet/templatetags/millify.py +++ b/snippet/templatetags/millify.py @@ -6,7 +6,7 @@ @register.filter def millify(n): - mill_names = ["", "K+", "M+"] + mill_names = ["", "K", "M"] n = float(n) mill_idx = max( 0, @@ -15,5 +15,7 @@ def millify(n): int(floor(0 if n == 0 else log10(abs(n)) / 3)), ), ) + + is_more = '+' if mill_names[mill_idx] else '' - return "{:.0f}{}".format(n / 10 ** (3 * mill_idx), mill_names[mill_idx]) + return "{}{:.0f}{}".format(is_more, n / 10 ** (3 * mill_idx), mill_names[mill_idx])