feeder: only update feeds currently configured

This commit is contained in:
ducklet 2020-11-07 21:22:36 +01:00
parent efc6ecbb45
commit 78777a4da9
2 changed files with 11 additions and 8 deletions

View file

@ -20,6 +20,7 @@ class Feeder:
def add_feeds(self, feeds: Iterable[Feed]): def add_feeds(self, feeds: Iterable[Feed]):
self.feeds.update({f.id: f for f in feeds}) self.feeds.update({f.id: f for f in feeds})
self.store.sync_feeds(self.feeds) self.store.sync_feeds(self.feeds)
log.debug("Active feeds: %s", ", ".join(self.feeds.keys()))
async def update_all(self) -> Mapping[FeedId, Set[PostId]]: async def update_all(self) -> Mapping[FeedId, Set[PostId]]:
new_post_ids = self.news = dict( new_post_ids = self.news = dict(

View file

@ -87,8 +87,8 @@ class Store:
for row in conn.execute(sql): for row in conn.execute(sql):
id, url, active = row id, url, active = row
if id not in feeds: if id not in feeds:
feeds[id] = Feed(id, url) continue
else:
if active: if active:
if feeds[id].url != url: if feeds[id].url != url:
log.warning(f"Feed URL changed: {id}: {url}") log.warning(f"Feed URL changed: {id}: {url}")
@ -105,6 +105,8 @@ class Store:
""" """
for row in conn.execute(sql): for row in conn.execute(sql):
post_id, feed_id = row post_id, feed_id = row
if feed_id not in feeds:
continue
if post_id not in post_ids[feed_id]: if post_id not in post_ids[feed_id]:
post_ids[feed_id].add(post_id) post_ids[feed_id].add(post_id)
feeds[feed_id].posts.append(Post(post_id)) feeds[feed_id].posts.append(Post(post_id))