diff --git a/generate_report.py b/generate_report.py index 4cf4495..ac46439 100644 --- a/generate_report.py +++ b/generate_report.py @@ -254,6 +254,10 @@ HTML_TEMPLATE = """
+
+
__TOTAL_LIBRARY__
+
Games in Library
+
0
Games Played
@@ -564,12 +568,16 @@ HTML_TEMPLATE = """ """ -def get_all_games(db_path: str) -> list[dict]: - """Query the database and return all games with playtime and categories.""" +def get_all_games(db_path: str) -> tuple[list[dict], int]: + """Query the database and return all games with playtime and categories, plus total library count.""" conn = sqlite3.connect(db_path) cursor = conn.cursor() - # Get games with playtime + # Get total games in library + cursor.execute("SELECT COUNT(*) FROM games") + total_library = cursor.fetchone()[0] + + # Get games with playtime > 0 cursor.execute(""" SELECT id, name, playtime, COALESCE(service, 'local') as service FROM games @@ -594,7 +602,7 @@ def get_all_games(db_path: str) -> list[dict]: game_categories[game_id] = [] game_categories[game_id].append(category) - return [ + games = [ { "name": row[1], "playtime": row[2], @@ -603,11 +611,12 @@ def get_all_games(db_path: str) -> list[dict]: } for row in games_rows ] + return games, total_library def generate_report(db_path: str, output_path: str, top_n: int, bg_image_path: str = None) -> None: """Generate the HTML report.""" - all_games = get_all_games(db_path) + all_games, total_library = get_all_games(db_path) if not all_games: print("No games with playtime found in the database.") @@ -625,10 +634,12 @@ def generate_report(db_path: str, output_path: str, top_n: int, bg_image_path: s html = HTML_TEMPLATE.replace("__ALL_GAMES__", json.dumps(all_games)) html = html.replace("__TOP_N__", str(top_n)) + html = html.replace("__TOTAL_LIBRARY__", str(total_library)) html = html.replace("__BACKGROUND_IMAGE__", bg_data_url) Path(output_path).write_text(html, encoding="utf-8") print(f"Report generated: {output_path}") + print(f"Total games in library: {total_library}") print(f"Total games with playtime: {total_games}") print(f"Total playtime: {total_playtime:.1f} hours")