rename __convert_to_list_of_dicts method to __dictrow_to_dict_list
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is failing

This commit is contained in:
mitsuha_s 2022-07-13 20:50:03 +00:00
parent feef909c61
commit 50ac344095

View file

@ -125,20 +125,20 @@ class Database:
"""Get a list of feeds.""" """Get a list of feeds."""
self.log.debug('find_feeds()') self.log.debug('find_feeds()')
self.cur.execute('SELECT * FROM feeds') self.cur.execute('SELECT * FROM feeds')
return self.__convert_to_list_of_dicts(self.cur.fetchall()) return self.__dictrow_to_dict_list(self.cur.fetchall())
def find_user_feeds(self, user_id: int) -> list[dict]: def find_user_feeds(self, user_id: int) -> list[dict]:
"""Return a list of feeds the user is subscribed to.""" """Return a list of feeds the user is subscribed to."""
self.log.debug('find_user_feeds(user_id=\'%s\')', user_id) self.log.debug('find_user_feeds(user_id=\'%s\')', user_id)
self.cur.execute('SELECT * FROM feeds WHERE id IN (SELECT feed_id FROM subscriptions WHERE user_id = %s)', self.cur.execute('SELECT * FROM feeds WHERE id IN (SELECT feed_id FROM subscriptions WHERE user_id = %s)',
[user_id]) [user_id])
return self.__convert_to_list_of_dicts(self.cur.fetchall()) return self.__dictrow_to_dict_list(self.cur.fetchall())
def find_feed_items(self, feed_id: int) -> list[dict]: def find_feed_items(self, feed_id: int) -> list[dict]:
"""Get last feed items.""" """Get last feed items."""
self.log.debug('find_feed_items(feed_id=\'%s\')', feed_id) self.log.debug('find_feed_items(feed_id=\'%s\')', feed_id)
self.cur.execute('SELECT * FROM feeds_last_items WHERE feed_id = %s', [feed_id]) self.cur.execute('SELECT * FROM feeds_last_items WHERE feed_id = %s', [feed_id])
return self.__convert_to_list_of_dicts(self.cur.fetchall()) return self.__dictrow_to_dict_list(self.cur.fetchall())
def find_feed_items_urls(self, feed_id: int) -> list[str]: def find_feed_items_urls(self, feed_id: int) -> list[str]:
"""Return urls last feed items""" """Return urls last feed items"""
@ -182,6 +182,6 @@ class Database:
) )
@staticmethod @staticmethod
def __convert_to_list_of_dicts(rows: list[DictRow]) -> list[dict]: def __dictrow_to_dict_list(rows: list[DictRow]) -> list[dict]:
"""Convert list of DictRows to list of dicts""" """Convert list of DictRows to list of dicts"""
return list(map(lambda x: dict(x), rows)) return list(map(lambda x: dict(x), rows))