Mercurial > hg > Feedworm
changeset 145:71c5dc02ff87
move the code from FeedList into the backend class
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Thu, 25 Aug 2011 05:39:03 +0200 |
parents | 74217db92993 |
children | 8ec20377bcb0 |
files | backend/sqlalchemy/FeedList.py backend/sqlalchemy/SqlAlchemyBackend.py |
diffstat | 2 files changed, 18 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/backend/sqlalchemy/FeedList.py Wed Aug 24 11:54:06 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ - -from Feed import Feed -from FeedEntry import FeedEntry -from Preferences import Preferences -from sqlalchemy.orm import joinedload - -def getFeeds(session): - preferences = Preferences(session) - if preferences.showOnlyUnreadFeeds(): - return _getUnreadFeeds(session) - else: - return Feed.all(session) - -def _getUnreadFeeds(session): - query = session.query(FeedEntry).filter(FeedEntry.read == 0) - queryWithOptions = query.options(joinedload("feed")) - result = queryWithOptions.all() - return _collectFeeds(result) - -def _collectFeeds(feedEntries): - feeds = [entry.feed for entry in feedEntries] - uniqueFeeds = set(feeds) - return list(uniqueFeeds)
--- a/backend/sqlalchemy/SqlAlchemyBackend.py Wed Aug 24 11:54:06 2011 +0200 +++ b/backend/sqlalchemy/SqlAlchemyBackend.py Thu Aug 25 05:39:03 2011 +0200 @@ -1,9 +1,11 @@ +from Feed import Feed +from FeedEntry import FeedEntry from Preferences import Preferences from datetime import datetime, timedelta +from sqlalchemy.orm import joinedload from sqlalchemy.sql import and_ import Database -import FeedList import FeedUpdater import Mapping import logging @@ -32,7 +34,21 @@ return self.prefs def getFeeds(self): - return FeedList.getFeeds(self.session) + if self.preferences().showOnlyUnreadFeeds(): + return self._getUnreadFeeds() + else: + return Feed.all(self.session) + + def _getUnreadFeeds(self): + query = self.session.query(FeedEntry).filter(FeedEntry.read == 0) + queryWithOptions = query.options(joinedload("feed")) + result = queryWithOptions.all() + return self._collectFeeds(result) + + def _collectFeeds(self, feedEntries): + feeds = [entry.feed for entry in feedEntries] + uniqueFeeds = set(feeds) + return list(uniqueFeeds) def toggleRead(self, feedEntry): feedEntry.toggleRead()