mirror of
https://github.com/mustbeperfect/definitive-opensource.git
synced 2026-04-19 13:54:17 +02:00
Added another way to handle .0
This commit is contained in:
@@ -20,6 +20,24 @@ def format_stars(n):
|
||||
return formatted.replace('.0k', 'k')
|
||||
else:
|
||||
return str(n)
|
||||
|
||||
'''
|
||||
def format_stars(n):
|
||||
if n >= 1_000_000:
|
||||
value = n / 1_000_000
|
||||
suffix = "M"
|
||||
elif n >= 1_000:
|
||||
value = n / 1_000
|
||||
suffix = "k"
|
||||
else:
|
||||
return str(n)
|
||||
|
||||
# If it's a whole number, don't show decimal point
|
||||
if value == int(value):
|
||||
return f"{int(value)}{suffix}"
|
||||
else:
|
||||
return f"{value:.1f}{suffix}"
|
||||
'''
|
||||
|
||||
def generate_contents(platform="all"):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user