Migrate to PostgreSQL #39

Merged
Miroslavsckaya merged 16 commits from migrate_to_postgresql into master 2022-07-13 22:53:54 +00:00
Showing only changes of commit 6535055268 - Show all commits

View file

@ -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."""