diff --git a/aocsync.py b/aocsync.py index 013ea18..70bb59e 100755 --- a/aocsync.py +++ b/aocsync.py @@ -1318,6 +1318,19 @@ class HTMLGenerator: for part in day.values(): users_with_data.update(part.keys()) + # Calculate stars (completed parts) per user per year + stars_by_user_year = defaultdict(lambda: defaultdict(int)) + for year in data: + for day in data[year].values(): + for part in day.values(): + for user, time_data in part.items(): + if isinstance(time_data, dict): + total_time = time_data.get('total', 0) + else: + total_time = time_data if time_data > 0 else 0 + if total_time > 0: + stars_by_user_year[user][year] += 1 + # Check if log file exists log_file_path = Path(config.output_dir) / 'cargo-aoc.log' log_file_exists = log_file_path.exists() @@ -1777,6 +1790,43 @@ class HTMLGenerator:
Users: """ + ', '.join(sorted(users)) + """
""" + (f'' if log_file_exists else '') + """ + + +Number of completed parts (stars) per user per year
+| User | +""" + # Add year columns + for year in sorted_years: + html += f"{year} | \n" + html += """Total | +|
|---|---|---|---|
| {user} | +""" + total_stars = 0 + for year in sorted_years: + stars = stars_by_user_year[user][year] + total_stars += stars + if stars > 0: + html += f"{stars} ⭐ | \n" + else: + html += "- | \n" + html += f"{total_stars} ⭐ | \n" + html += "