Updated script so 60.0k shows as 60k

This commit is contained in:
Lucas
2025-04-10 21:18:20 -07:00
parent 2dad1d89f1
commit e66edbd2b5

View File

@@ -13,12 +13,19 @@ def extract_repo_path(link):
def format_stars(n):
if n >= 1_000_000:
return f"{n/1_000_000:.1f}M"
value = n / 1_000_000
suffix = 'M'
elif n >= 1_000:
return f"{n/1_000:.1f}k"
value = n / 1_000
suffix = 'k'
else:
return str(n)
if value.is_integer():
return f"{int(value)}{suffix}"
else:
return f"{value:.1f}{suffix}"
def generate_contents(platform="all"):
with open("source/data/categories.json", "r", encoding="utf-8") as f: