From acd8c4ce0654c1c5271c583045dc74bf2e3b957d Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Sat, 21 Feb 2026 20:41:29 -0500 Subject: [PATCH] fix(platforms): exclude 'games' from platforms/all.json summary Calculate and attach per-platform game counts as before, but write a lightweight platforms/all.json that omits the full 'games' lists to keep the summary file small (fits GitHub Pages limits). Adds a brief explanatory comment/docstring and builds summary_data without 'games' before calling write_json_files. Updates unit test to verify the 'games' key is not present in the written summary and that game_count and platform name remain correct. --- src/update_db.py | 12 +++++++++++- tests/unit/test_update_db.py | 6 ++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/update_db.py b/src/update_db.py index a35e177bd7a7..bdf0917dd936 100644 --- a/src/update_db.py +++ b/src/update_db.py @@ -305,6 +305,10 @@ def _add_platform_game_counts(full_dict: dict) -> None: """ Calculate and attach game counts to each platform, then rewrite platforms/all.json. + The ``games`` list (appended by :func:`_append_related_items`) is intentionally excluded from + the ``all.json`` summary file because it would make the file excessively large. The full game + list is still available in each individual platform JSON file. + Parameters ---------- full_dict : dict @@ -314,8 +318,14 @@ def _add_platform_game_counts(full_dict: dict) -> None: for platform_data in full_dict['platforms'].values(): platform_data['game_count'] = len(platform_data.get('games', [])) + # Write a lightweight all.json that omits the 'games' list so the file stays small enough + # to be hosted on GitHub Pages (< 100 MB limit). + summary_data = { + pid: {k: v for k, v in pdata.items() if k != 'games'} + for pid, pdata in full_dict['platforms'].items() + } file_path = os.path.join(args.out_dir, 'platforms', 'all') - write_json_files(file_path=file_path, data=full_dict['platforms']) + write_json_files(file_path=file_path, data=summary_data) def _build_buckets_and_collect_videos(full_dict: dict) -> tuple: diff --git a/tests/unit/test_update_db.py b/tests/unit/test_update_db.py index ee1b2b5f42e0..d4845d3cf7ab 100644 --- a/tests/unit/test_update_db.py +++ b/tests/unit/test_update_db.py @@ -271,6 +271,12 @@ def test_add_platform_game_counts(tmp_path): assert full_dict['platforms'][6]['game_count'] == 2 assert full_dict['platforms'][48]['game_count'] == 0 mock_write.assert_called_once() + # Verify the 'games' list is excluded from the summary written to all.json + written_data = mock_write.call_args.kwargs['data'] + assert 'games' not in written_data[6] + assert 'games' not in written_data[48] + assert written_data[6]['game_count'] == 2 + assert written_data[6]['name'] == 'PC' @pytest.mark.parametrize('name,expected_bucket', [