Mercurial > hg > Feedworm
comparison backend/sqlalchemy/FeedList.py @ 119:04a730f9d07d backend
move all sqlalchemy related classes to the respective sub-package. use a backend to abstract from access to the data
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Sun, 21 Aug 2011 03:55:16 +0200 |
parents | FeedList.py@5585f3d23541 |
children |
comparison
equal
deleted
inserted
replaced
118:0e73adb2dec4 | 119:04a730f9d07d |
---|---|
1 | |
2 from Feed import Feed | |
3 from FeedEntry import FeedEntry | |
4 from Preferences import Preferences | |
5 from sqlalchemy.orm import joinedload | |
6 | |
7 def getFeeds(session): | |
8 preferences = Preferences(session) | |
9 if preferences.showOnlyUnreadFeeds(): | |
10 return _getUnreadFeeds(session) | |
11 else: | |
12 return Feed.all(session) | |
13 | |
14 def _getUnreadFeeds(session): | |
15 query = session.query(FeedEntry).filter(FeedEntry.read == 0) | |
16 queryWithOptions = query.options(joinedload("feed")) | |
17 result = queryWithOptions.all() | |
18 return _collectFeeds(result) | |
19 | |
20 def _collectFeeds(feedEntries): | |
21 feeds = [entry.feed for entry in feedEntries] | |
22 uniqueFeeds = set(feeds) | |
23 return list(uniqueFeeds) |