fix: round GitHub stars to whole numbers in HTML output

This commit is contained in:
Paul Gauthier (aider) 2025-03-20 14:28:58 -07:00
parent 0937b34983
commit 57ce2c48b8

View file

@ -205,7 +205,17 @@ def get_badges_html():
# Format values
downloads_formatted = format_number(total_downloads)
stars_formatted = format_number(stars) if stars is not None else "0"
# Stars should be rounded to whole numbers
if stars is None:
stars_formatted = "0"
elif stars >= 1_000_000_000:
stars_formatted = f"{stars // 1_000_000_000}B"
elif stars >= 1_000_000:
stars_formatted = f"{stars // 1_000_000}M"
elif stars >= 1_000:
stars_formatted = f"{stars // 1_000}K"
else:
stars_formatted = str(stars)
aider_percent_rounded = round(percentage)
# Generate HTML badges