Skip to content

Commit

Permalink
Storage.mark_as_stale(str) -> set_feed_stale(str, bool).
Browse files Browse the repository at this point in the history
For #325.
  • Loading branch information
lemon24 committed Oct 26, 2023
1 parent 6319750 commit cd261f0
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
5 changes: 3 additions & 2 deletions src/reader/_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,10 +703,11 @@ def set_feed_updates_enabled(self, url: str, enabled: bool) -> None:
rowcount_exactly_one(cursor, lambda: FeedNotFoundError(url))

@wrap_exceptions(StorageError)
def mark_as_stale(self, url: str) -> None:
def set_feed_stale(self, url: str, stale: bool) -> None:
with self.get_db() as db:
cursor = db.execute(
"UPDATE feeds SET stale = 1 WHERE url = :url;", dict(url=url)
"UPDATE feeds SET stale = :stale WHERE url = :url;",
dict(url=url, stale=stale),
)
rowcount_exactly_one(cursor, lambda: FeedNotFoundError(url))

Expand Down
9 changes: 4 additions & 5 deletions src/reader/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ class FeedForUpdate(NamedTuple):
http_last_modified: str | None

#: Whether the next update should update *all* entries,
#: regardless of their .updated.
#: regardless of their :attr:`hash` or :attr:`updated`.
stale: bool

#: The date the feed was last updated, according to reader; none if never.
Expand Down Expand Up @@ -675,12 +675,11 @@ class StorageType(Protocol): # pragma: no cover
Update methods:
* get_feeds_for_update
* get_entries_for_update
* update_feed
* set_feed_stale
* get_entries_for_update
* add_or_update_entries
* is this a good name?
* mark_as_stale
* only used in tests, remove? if not, rename
* get_entry_recent_sort
* set_entry_recent_sort
Expand Down Expand Up @@ -742,7 +741,7 @@ def set_feed_user_title(self, url: str, title: str | None) -> None:
def set_feed_updates_enabled(self, url: str, enabled: bool) -> None:
...

def mark_as_stale(self, url: str) -> None:
def set_feed_stale(self, url: str, stale: bool) -> None:
...

def set_entry_read(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -1988,7 +1988,7 @@ def test_change_feed_url_feeds_for_update(reader):
reader._parser.condition = lambda url: url == '1'
reader.update_feeds()

reader._storage.mark_as_stale('1')
reader._storage.set_feed_stale('1', True)

def get_feed(feed):
return next(
Expand Down
4 changes: 2 additions & 2 deletions tests/test_reader_private.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_update_stale(reader, update_feed, entry_updated):
entry = parser.entry(1, 1, entry_updated)

with pytest.raises(FeedNotFoundError):
reader._storage.mark_as_stale(feed.url)
reader._storage.set_feed_stale(feed.url, True)

reader.add_feed(feed.url)

Expand Down Expand Up @@ -73,7 +73,7 @@ def test_update_stale(reader, update_feed, entry_updated):

# but it does if we mark the feed as stale
parser.calls[:] = []
reader._storage.mark_as_stale(feed.url)
reader._storage.set_feed_stale(feed.url, True)
reader._now = lambda: naive_datetime(2010, 1, 3)
update_feed(reader, feed.url)
assert parser.calls == [(feed.url, None, None)]
Expand Down
6 changes: 3 additions & 3 deletions tests/test_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ def set_feed_updates_enabled(storage, feed, __):
storage.set_feed_updates_enabled(feed.url, 1)


def mark_as_stale(storage, feed, __):
storage.mark_as_stale(feed.url)
def set_feed_stale(storage, feed, __):
storage.set_feed_stale(feed.url, True)


def set_entry_read(storage, feed, entry):
Expand Down Expand Up @@ -314,7 +314,7 @@ def get_entry_last(storage, feed, entry):
get_entries_for_update,
set_feed_user_title,
set_feed_updates_enabled,
mark_as_stale,
set_feed_stale,
set_entry_read,
set_entry_important,
get_entry_recent_sort,
Expand Down

0 comments on commit cd261f0

Please sign in to comment.