diff --git a/src/reader/_search.py b/src/reader/_search.py index 71b52686..cf73181a 100644 --- a/src/reader/_search.py +++ b/src/reader/_search.py @@ -747,7 +747,6 @@ def _insert_into_search_one_chunk(self) -> bool: def search_entries( self, query: str, - now: datetime, filter_options: EntryFilterOptions = EntryFilterOptions(), # noqa: B008 sort: SearchSortOrder = 'relevant', limit: int | None = None, @@ -758,12 +757,12 @@ def search_entries( last = None if starting_after: if sort == 'recent': - last = self.storage.get_entry_last(now, sort, starting_after) + last = self.storage.get_entry_last(sort, starting_after) else: last = self.search_entry_last(query, starting_after) rv = join_paginated_iter( - partial(self.search_entries_page, query, now, filter_options, sort), # type: ignore[arg-type] + partial(self.search_entries_page, query, filter_options, sort), # type: ignore[arg-type] self.chunk_size, last, limit or 0, @@ -773,7 +772,6 @@ def search_entries( assert not starting_after it = self.search_entries_page( query, - now, filter_options, sort, min(limit, self.chunk_size or limit) if limit else self.chunk_size, @@ -810,7 +808,6 @@ def search_entry_last(self, query: str, entry: tuple[str, str]) -> tuple[Any, .. def search_entries_page( self, query: str, - now: datetime, filter_options: EntryFilterOptions = EntryFilterOptions(), # noqa: B008 sort: SearchSortOrder = 'relevant', chunk_size: int | None = None, diff --git a/src/reader/_storage.py b/src/reader/_storage.py index 5cdaee5a..890e15ae 100644 --- a/src/reader/_storage.py +++ b/src/reader/_storage.py @@ -1056,7 +1056,6 @@ def delete_entries( def get_entries( self, - now: datetime, filter_options: EntryFilterOptions = EntryFilterOptions(), # noqa: B008 sort: EntrySortOrder = 'recent', limit: int | None = None, @@ -1065,17 +1064,14 @@ def get_entries( # TODO: deduplicate if sort == 'recent': rv = join_paginated_iter( - partial(self.get_entries_page, now, filter_options, sort), # type: ignore[arg-type] + partial(self.get_entries_page, filter_options, sort), # type: ignore[arg-type] self.chunk_size, - self.get_entry_last(now, sort, starting_after) - if starting_after - else None, + self.get_entry_last(sort, starting_after) if starting_after else None, limit or 0, ) elif sort == 'random': assert not starting_after it = self.get_entries_page( - now, filter_options, sort, min(limit, self.chunk_size or limit) if limit else self.chunk_size, @@ -1087,9 +1083,7 @@ def get_entries( yield from rv @wrap_exceptions(StorageError) - def get_entry_last( - self, now: datetime, sort: str, entry: tuple[str, str] - ) -> tuple[Any, ...]: + def get_entry_last(self, sort: str, entry: tuple[str, str]) -> tuple[Any, ...]: # TODO: make this method private? feed_url, entry_id = entry @@ -1114,7 +1108,6 @@ def get_entry_last( @wrap_exceptions_iter(StorageError) def get_entries_page( self, - now: datetime, filter_options: EntryFilterOptions = EntryFilterOptions(), # noqa: B008 sort: EntrySortOrder = 'recent', chunk_size: int | None = None, diff --git a/src/reader/_types.py b/src/reader/_types.py index db3157ed..c18f4fa2 100644 --- a/src/reader/_types.py +++ b/src/reader/_types.py @@ -778,7 +778,6 @@ def delete_entries( def get_entries( self, - now: datetime, filter_options: EntryFilterOptions, sort: EntrySortOrder, limit: int | None, @@ -824,7 +823,6 @@ def update(self) -> None: def search_entries( self, query: str, - now: datetime, filter_options: EntryFilterOptions, sort: SearchSortOrder, limit: int | None, diff --git a/src/reader/core.py b/src/reader/core.py index 8da4dcf1..7e058b22 100644 --- a/src/reader/core.py +++ b/src/reader/core.py @@ -1204,9 +1204,7 @@ def get_entries( if starting_after and sort == 'random': raise ValueError("using starting_after with sort='random' not supported") - now = self._now() rv = self._storage.get_entries( - now, filter_options, sort, limit, @@ -1797,10 +1795,8 @@ def search_entries( if starting_after and sort == 'random': raise ValueError("using starting_after with sort='random' not supported") - now = self._now() return self._search.search_entries( query, - now, filter_options, sort, limit, diff --git a/tests/test_search.py b/tests/test_search.py index ba58503c..5b406ba1 100644 --- a/tests/test_search.py +++ b/tests/test_search.py @@ -49,15 +49,11 @@ def update_search(storage, _, __): def search_entries_chunk_size_0(storage, _, __): - list( - Search(storage).search_entries_page('entry', datetime(2010, 1, 1), chunk_size=0) - ) + list(Search(storage).search_entries_page('entry', chunk_size=0)) def search_entries_chunk_size_1(storage, _, __): - list( - Search(storage).search_entries_page('entry', datetime(2010, 1, 1), chunk_size=1) - ) + list(Search(storage).search_entries_page('entry', chunk_size=1)) def search_entry_counts(storage, _, __): @@ -97,27 +93,19 @@ def enable_and_update_search(storage): def iter_search_entries_chunk_size_0(storage): - return Search(storage).search_entries_page( - 'entry', datetime(2010, 1, 1), chunk_size=0 - ) + return Search(storage).search_entries_page('entry', chunk_size=0) def iter_search_entries_chunk_size_1(storage): - return Search(storage).search_entries_page( - 'entry', datetime(2010, 1, 1), chunk_size=1 - ) + return Search(storage).search_entries_page('entry', chunk_size=1) def iter_search_entries_chunk_size_2(storage): - return Search(storage).search_entries_page( - 'entry', datetime(2010, 1, 1), chunk_size=2 - ) + return Search(storage).search_entries_page('entry', chunk_size=2) def iter_search_entries_chunk_size_3(storage): - return Search(storage).search_entries_page( - 'entry', datetime(2010, 1, 1), chunk_size=3 - ) + return Search(storage).search_entries_page('entry', chunk_size=3) @pytest.mark.slow @@ -149,7 +137,7 @@ class ActuallyOK(Exception): def call_search_entries(search, query): try: - next(search.search_entries(query, datetime(2010, 1, 1))) + next(search.search_entries(query)) except StopIteration: raise ActuallyOK diff --git a/tests/test_storage.py b/tests/test_storage.py index e1abf0ee..df6dce8b 100644 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -267,11 +267,11 @@ def delete_entries(storage, feed, entry): def get_entries_chunk_size_0(storage, _, __): - list(storage.get_entries_page(chunk_size=0, now=datetime(2010, 1, 1))) + list(storage.get_entries_page(chunk_size=0)) def get_entries_chunk_size_1(storage, _, __): - list(storage.get_entries_page(chunk_size=1, now=datetime(2010, 1, 1))) + list(storage.get_entries_page(chunk_size=1)) def get_tags(storage, feed, __): @@ -299,7 +299,7 @@ def get_feed_last(storage, feed, __): def get_entry_last(storage, feed, entry): - storage.get_entry_last(datetime(2010, 1, 1), 'recent', (feed.url, entry.id)) + storage.get_entry_last('recent', (feed.url, entry.id)) @pytest.mark.slow @@ -402,19 +402,19 @@ def iter_get_feeds_for_update(storage): def iter_pagination_chunk_size_0(storage): - return storage.get_entries_page(chunk_size=0, now=datetime(2010, 1, 1)) + return storage.get_entries_page(chunk_size=0) def iter_pagination_chunk_size_1(storage): - return storage.get_entries_page(chunk_size=1, now=datetime(2010, 1, 1)) + return storage.get_entries_page(chunk_size=1) def iter_pagination_chunk_size_2(storage): - return storage.get_entries_page(chunk_size=2, now=datetime(2010, 1, 1)) + return storage.get_entries_page(chunk_size=2) def iter_pagination_chunk_size_3(storage): - return storage.get_entries_page(chunk_size=3, now=datetime(2010, 1, 1)) + return storage.get_entries_page(chunk_size=3) def iter_get_tags(storage): @@ -533,10 +533,7 @@ def storage_with_two_entries(storage): @rename_argument('storage', 'storage_with_two_entries') def test_important_unimportant_by_default(storage): assert { - e.id - for e in storage.get_entries( - datetime(2010, 1, 1), EntryFilterOptions(important='nottrue') - ) + e.id for e in storage.get_entries(EntryFilterOptions(important='nottrue')) } == {'one', 'two'} @@ -544,27 +541,19 @@ def test_important_unimportant_by_default(storage): def test_important_get_entries(storage): storage.set_entry_important(('feed', 'one'), True, datetime(2010, 1, 2)) - assert {e.id for e in storage.get_entries(now=datetime(2010, 1, 1))} == { + assert {e.id for e in storage.get_entries()} == { + 'one', + 'two', + } + assert {e.id for e in storage.get_entries(EntryFilterOptions(important='any'))} == { 'one', 'two', } assert { - e.id - for e in storage.get_entries( - datetime(2010, 1, 1), EntryFilterOptions(important='any') - ) - } == {'one', 'two'} - assert { - e.id - for e in storage.get_entries( - datetime(2010, 1, 1), EntryFilterOptions(important='istrue') - ) + e.id for e in storage.get_entries(EntryFilterOptions(important='istrue')) } == {'one'} assert { - e.id - for e in storage.get_entries( - datetime(2010, 1, 1), EntryFilterOptions(important='nottrue') - ) + e.id for e in storage.get_entries(EntryFilterOptions(important='nottrue')) } == {'two'} @@ -572,7 +561,7 @@ def test_important_get_entries(storage): def test_important_entry_important(storage): storage.set_entry_important(('feed', 'one'), True, None) - assert {e.id: e.important for e in storage.get_entries(datetime(2010, 1, 1))} == { + assert {e.id: e.important for e in storage.get_entries()} == { 'one': True, 'two': None, } @@ -584,10 +573,7 @@ def test_important_mark_as_unimportant(storage): storage.set_entry_important(('feed', 'one'), False, None) assert { - e.id - for e in storage.get_entries( - datetime(2010, 1, 1), EntryFilterOptions(important='istrue') - ) + e.id for e in storage.get_entries(EntryFilterOptions(important='istrue')) } == set()