feeder: only update feeds currently configured
This commit is contained in:
parent
efc6ecbb45
commit
78777a4da9
2 changed files with 11 additions and 8 deletions
|
|
@ -20,6 +20,7 @@ class Feeder:
|
|||
def add_feeds(self, feeds: Iterable[Feed]):
|
||||
self.feeds.update({f.id: f for f in 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]]:
|
||||
new_post_ids = self.news = dict(
|
||||
|
|
|
|||
|
|
@ -87,15 +87,15 @@ class Store:
|
|||
for row in conn.execute(sql):
|
||||
id, url, active = row
|
||||
if id not in feeds:
|
||||
feeds[id] = Feed(id, url)
|
||||
continue
|
||||
|
||||
if active:
|
||||
if feeds[id].url != url:
|
||||
log.warning(f"Feed URL changed: {id}: {url}")
|
||||
feeds[id].url = url
|
||||
else:
|
||||
if active:
|
||||
if feeds[id].url != url:
|
||||
log.warning(f"Feed URL changed: {id}: {url}")
|
||||
feeds[id].url = url
|
||||
else:
|
||||
log.warning(f"Feed is marked inactive: {id}")
|
||||
del feeds[id]
|
||||
log.warning(f"Feed is marked inactive: {id}")
|
||||
del feeds[id]
|
||||
|
||||
post_ids = {f.id: f.post_ids for f in feeds.values()}
|
||||
sql = """
|
||||
|
|
@ -105,6 +105,8 @@ class Store:
|
|||
"""
|
||||
for row in conn.execute(sql):
|
||||
post_id, feed_id = row
|
||||
if feed_id not in feeds:
|
||||
continue
|
||||
if post_id not in post_ids[feed_id]:
|
||||
post_ids[feed_id].add(post_id)
|
||||
feeds[feed_id].posts.append(Post(post_id))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue