diff --git a/backend/endpoints/roms/__init__.py b/backend/endpoints/roms/__init__.py index 0a0eaf92e..9892904f1 100644 --- a/backend/endpoints/roms/__init__.py +++ b/backend/endpoints/roms/__init__.py @@ -159,11 +159,6 @@ router.include_router(patch_router) # RomUser fields the statuses filter branches on. STATUS_MEMBERSHIP_FIELDS = frozenset({"status", "now_playing", "backlogged", "hidden"}) -# Anniversaries are paged through one card at a time, so the cap is a ceiling on -# a widget's payload rather than a page size. -DEFAULT_ANNIVERSARY_LIMIT = 24 -MAX_ANNIVERSARY_LIMIT = 50 - def safe_int_or_none(value: Any) -> int | None: if value is None or value == "": @@ -1117,18 +1112,17 @@ def get_anniversary_roms( description="Day of the month, defaulting to today's UTC date.", ge=1, le=31 ), ] = None, - limit: Annotated[ - int, - Query(ge=1, le=MAX_ANNIVERSARY_LIMIT, description="Maximum roms to return"), - ] = DEFAULT_ANNIVERSARY_LIMIT, ) -> list[SimpleRomSchema]: - """Roms released on a given day of an earlier year, oldest release first. + """Every rom released on a given day of an earlier year, oldest release first. Whole-library, so it takes no scope: it feeds the Home widget, which shows one game at a time and pages through the rest. Clients pass their own local month and day so "today" matches the calendar in front of the user. - Empty on 1 January, which several providers use for year-only metadata. + Uncapped, so the widget's counter is a real total. That makes the 1 January + skip below load-bearing for response size as well as for accuracy: several + providers park year-only metadata there, which is the one day of the year + that would answer with a sizeable fraction of the library. """ perms = get_permissions(request) @@ -1146,7 +1140,6 @@ def get_anniversary_roms( today=datetime.now(timezone.utc).date(), month=month, day=day, - limit=limit, ) if not rom_ids: return [] diff --git a/backend/handler/database/roms_handler.py b/backend/handler/database/roms_handler.py index 9234f8bc1..fb4376af0 100644 --- a/backend/handler/database/roms_handler.py +++ b/backend/handler/database/roms_handler.py @@ -1920,10 +1920,9 @@ class DBRomsHandler(DBBaseHandler): today: date, month: int | None = None, day: int | None = None, - limit: int, session: Session = None, # type: ignore ) -> list[int]: - """Ids of roms released on a given day of the year, oldest release first. + """Ids of every rom released on a given day of the year, oldest release first. `idx_roms_generated_first_release_date` serves both the day-of-year match and the sort as one range scan, and only the id is selected, so the wide @@ -1934,7 +1933,6 @@ class DBRomsHandler(DBBaseHandler): decides the leap-day rollover. month: Calendar month, defaulting to `today`'s. day: Day of the month, defaulting to `today`'s. - limit: Maximum ids to return. Returns: Rom ids, oldest release first. Empty on 1 January. @@ -1961,7 +1959,6 @@ class DBRomsHandler(DBBaseHandler): .with_only_columns(Rom.id) # type: ignore .where(epoch_ms_in_ranges(Rom.generated_first_release_date, ranges)) .order_by(Rom.generated_first_release_date.asc()) - .limit(limit) ) return list(session.scalars(id_query).all()) diff --git a/backend/tests/endpoints/roms/test_anniversaries.py b/backend/tests/endpoints/roms/test_anniversaries.py index ace44bdc0..459fa6e05 100644 --- a/backend/tests/endpoints/roms/test_anniversaries.py +++ b/backend/tests/endpoints/roms/test_anniversaries.py @@ -174,16 +174,19 @@ def test_undated_roms_are_not_returned( assert response.json() == [] -def test_caps_the_result_list( +def test_returns_every_match_for_the_day( client: TestClient, access_token: str, platform: Platform ) -> None: - for year in range(1990, 1996): + """Uncapped, so the widget's counter is a real total rather than a ceiling.""" + for year in range(1970, 2000): _dated_rom(platform, f"rom_{year}", date(year, 9, 8)) - response = _get(client, access_token, month=9, day=8, limit=2) + response = _get(client, access_token, month=9, day=8) assert response.status_code == status.HTTP_200_OK - assert [rom["name"] for rom in response.json()] == ["rom_1990", "rom_1991"] + assert [rom["name"] for rom in response.json()] == [ + f"rom_{year}" for year in range(1970, 2000) + ] @pytest.mark.parametrize( @@ -192,7 +195,6 @@ def test_caps_the_result_list( {"month": 13, "day": 1}, {"month": 0, "day": 1}, {"month": 9, "day": 32}, - {"month": 9, "day": 8, "limit": 500}, ], ) def test_rejects_out_of_range_parameters( diff --git a/backend/tests/handler/database/test_roms_anniversaries.py b/backend/tests/handler/database/test_roms_anniversaries.py index e9423fc6c..43ba5fab6 100644 --- a/backend/tests/handler/database/test_roms_anniversaries.py +++ b/backend/tests/handler/database/test_roms_anniversaries.py @@ -46,7 +46,7 @@ def _dated_rom(platform: Platform, name: str, released: date | None) -> Rom: def _anniversary_names(today: date, month: int | None = None, day: int | None = None): query, _ = db_rom_handler.get_roms_query() ids = db_rom_handler.get_anniversary_rom_ids( - query=query, today=today, month=month, day=day, limit=24 + query=query, today=today, month=month, day=day ) by_id = {rom.id: rom.name for rom in db_rom_handler.get_roms_simple_by_ids(ids)} return [by_id[rom_id] for rom_id in ids] @@ -103,16 +103,12 @@ class TestMatching: assert _anniversary_names(date(2026, 9, 8)) == ["released_before"] - def test_respects_the_limit(self, platform: Platform): - for year in range(1990, 2000): + def test_returns_every_match(self, platform: Platform): + """No cap: the day's whole list is what the widget pages through.""" + for year in range(1970, 2000): _dated_rom(platform, f"rom_{year}", date(year, 9, 8)) - query, _ = db_rom_handler.get_roms_query() - ids = db_rom_handler.get_anniversary_rom_ids( - query=query, today=date(2026, 9, 8), limit=3 - ) - - assert len(ids) == 3 + assert len(_anniversary_names(date(2026, 9, 8))) == 30 class TestYearBoundary: