feat: Add fast startup fetch and background caching

- Add  for quick startup using first N feeds
- Add background thread for full fetch and caching
- Update  to use fast fetch
- Update docs and skills
This commit is contained in:
2026-03-19 22:38:55 -07:00
parent 4f2cf49a80
commit 7eaa441574
13 changed files with 393 additions and 220 deletions

View File

@@ -31,12 +31,12 @@ class TestFetchFeed:
@patch("engine.fetch.urllib.request.urlopen")
def test_fetch_network_error(self, mock_urlopen):
"""Network error returns None."""
"""Network error returns tuple with None feed."""
mock_urlopen.side_effect = Exception("Network error")
result = fetch_feed("http://example.com/feed")
url, feed = fetch_feed("http://example.com/feed")
assert result is None
assert feed is None
class TestFetchAll:
@@ -54,7 +54,7 @@ class TestFetchAll:
{"title": "Headline 1", "published_parsed": (2024, 1, 1, 12, 0, 0)},
{"title": "Headline 2", "updated_parsed": (2024, 1, 2, 12, 0, 0)},
]
mock_fetch_feed.return_value = mock_feed
mock_fetch_feed.return_value = ("http://example.com", mock_feed)
mock_skip.return_value = False
mock_strip.side_effect = lambda x: x
@@ -67,7 +67,7 @@ class TestFetchAll:
@patch("engine.fetch.boot_ln")
def test_fetch_all_feed_error(self, mock_boot, mock_fetch_feed):
"""Feed error increments failed count."""
mock_fetch_feed.return_value = None
mock_fetch_feed.return_value = ("http://example.com", None)
items, linked, failed = fetch_all()
@@ -87,7 +87,7 @@ class TestFetchAll:
{"title": "Sports scores"},
{"title": "Valid headline"},
]
mock_fetch_feed.return_value = mock_feed
mock_fetch_feed.return_value = ("http://example.com", mock_feed)
mock_skip.side_effect = lambda x: x == "Sports scores"
mock_strip.side_effect = lambda x: x