Skip to content

Commit 0531f47

Browse files
fix(platforms): exclude 'games' from platforms/all.json summary (#211)
1 parent 05d4a55 commit 0531f47

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

src/update_db.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,10 @@ def _add_platform_game_counts(full_dict: dict) -> None:
305305
"""
306306
Calculate and attach game counts to each platform, then rewrite platforms/all.json.
307307
308+
The ``games`` list (appended by :func:`_append_related_items`) is intentionally excluded from
309+
the ``all.json`` summary file because it would make the file excessively large. The full game
310+
list is still available in each individual platform JSON file.
311+
308312
Parameters
309313
----------
310314
full_dict : dict
@@ -314,8 +318,14 @@ def _add_platform_game_counts(full_dict: dict) -> None:
314318
for platform_data in full_dict['platforms'].values():
315319
platform_data['game_count'] = len(platform_data.get('games', []))
316320

321+
# Write a lightweight all.json that omits the 'games' list so the file stays small enough
322+
# to be hosted on GitHub Pages (< 100 MB limit).
323+
summary_data = {
324+
pid: {k: v for k, v in pdata.items() if k != 'games'}
325+
for pid, pdata in full_dict['platforms'].items()
326+
}
317327
file_path = os.path.join(args.out_dir, 'platforms', 'all')
318-
write_json_files(file_path=file_path, data=full_dict['platforms'])
328+
write_json_files(file_path=file_path, data=summary_data)
319329

320330

321331
def _build_buckets_and_collect_videos(full_dict: dict) -> tuple:

tests/unit/test_update_db.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,12 @@ def test_add_platform_game_counts(tmp_path):
271271
assert full_dict['platforms'][6]['game_count'] == 2
272272
assert full_dict['platforms'][48]['game_count'] == 0
273273
mock_write.assert_called_once()
274+
# Verify the 'games' list is excluded from the summary written to all.json
275+
written_data = mock_write.call_args.kwargs['data']
276+
assert 'games' not in written_data[6]
277+
assert 'games' not in written_data[48]
278+
assert written_data[6]['game_count'] == 2
279+
assert written_data[6]['name'] == 'PC'
274280

275281

276282
@pytest.mark.parametrize('name,expected_bucket', [

0 commit comments

Comments
 (0)