refuse to unpack the dict in UpdateManager
This commit is contained in:
parent
ae31be33b6
commit
6535055268
|
@ -25,20 +25,19 @@ class UpdateManager:
|
||||||
self.log.info('Feeds to update: %d', len(feeds))
|
self.log.info('Feeds to update: %d', len(feeds))
|
||||||
|
|
||||||
for feed in feeds:
|
for feed in feeds:
|
||||||
feed_id, feed_url = feed.values()
|
self.log.info('Processing [%d] %s', feed['id'], feed['url'])
|
||||||
self.log.info('Processing [%d] %s', feed_id, feed_url)
|
feed_obj = self.rss_reader.get_feed(feed['url'])
|
||||||
feed = self.rss_reader.get_feed(feed_url)
|
new_items = feed_obj.items
|
||||||
new_items = feed.items
|
old_items_urls = self.database.find_feed_items_urls(feed['id'])
|
||||||
old_items_urls = self.database.find_feed_items_urls(feed_id)
|
|
||||||
|
|
||||||
diff = self.__calculate_difference(new_items, old_items_urls)
|
diff = self.__calculate_difference(new_items, old_items_urls)
|
||||||
|
|
||||||
if not diff:
|
if not diff:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
chat_ids = self.database.find_feed_subscribers(feed_id)
|
chat_ids = self.database.find_feed_subscribers(feed['id'])
|
||||||
self.notifier.send_updates(chat_ids, diff, feed.title)
|
self.notifier.send_updates(chat_ids, diff, feed_obj.title)
|
||||||
self.database.update_feed_items(feed_id, new_items)
|
self.database.update_feed_items(feed['id'], new_items)
|
||||||
|
|
||||||
def __calculate_difference(self, new_items: list[FeedItem], old_items_urls: list[str]) -> list[FeedItem]:
|
def __calculate_difference(self, new_items: list[FeedItem], old_items_urls: list[str]) -> list[FeedItem]:
|
||||||
"""Calculate new feed items."""
|
"""Calculate new feed items."""
|
||||||
|
|
Loading…
Reference in a new issue