Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/update_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/test_update_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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', [
Expand Down