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