本文整理汇总了Python中apps.reader.models.UserSubscription.feeds_with_updated_counts方法的典型用法代码示例。如果您正苦于以下问题:Python UserSubscription.feeds_with_updated_counts方法的具体用法?Python UserSubscription.feeds_with_updated_counts怎么用?Python UserSubscription.feeds_with_updated_counts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类apps.reader.models.UserSubscription
的用法示例。
在下文中一共展示了UserSubscription.feeds_with_updated_counts方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: refresh_feeds
# 需要导入模块: from apps.reader.models import UserSubscription [as 别名]
# 或者: from apps.reader.models.UserSubscription import feeds_with_updated_counts [as 别名]
def refresh_feeds(request):
user = get_user(request)
feed_ids = request.REQUEST.getlist('feed_id')
check_fetch_status = request.REQUEST.get('check_fetch_status')
favicons_fetching = request.REQUEST.getlist('favicons_fetching')
start = datetime.datetime.utcnow()
feeds = UserSubscription.feeds_with_updated_counts(user, feed_ids=feed_ids,
check_fetch_status=check_fetch_status)
favicons_fetching = [int(f) for f in favicons_fetching if f]
feed_icons = dict([(i.feed_id, i) for i in MFeedIcon.objects(feed_id__in=favicons_fetching)])
for feed_id, feed in feeds.items():
if feed_id in favicons_fetching and feed_id in feed_icons:
feeds[feed_id]['favicon'] = feed_icons[feed_id].data
feeds[feed_id]['favicon_color'] = feed_icons[feed_id].color
feeds[feed_id]['favicon_fetching'] = feed.get('favicon_fetching')
user_subs = UserSubscription.objects.select_related('feed').filter(user=user, active=True)
sub_feed_ids = [s.feed_id for s in user_subs]
if favicons_fetching:
moved_feed_ids = [f for f in favicons_fetching if f not in sub_feed_ids]
for moved_feed_id in moved_feed_ids:
duplicate_feeds = DuplicateFeed.objects.filter(duplicate_feed_id=moved_feed_id)
if duplicate_feeds and duplicate_feeds[0].feed.pk in feeds:
feeds[moved_feed_id] = feeds[duplicate_feeds[0].feed.pk]
feeds[moved_feed_id]['dupe_feed_id'] = duplicate_feeds[0].feed.pk
if check_fetch_status:
missing_feed_ids = list(set(feed_ids) - set(sub_feed_ids))
if missing_feed_ids:
duplicate_feeds = DuplicateFeed.objects.filter(duplicate_feed_id__in=missing_feed_ids)
for duplicate_feed in duplicate_feeds:
feeds[duplicate_feed.duplicate_feed_id] = {'id': duplicate_feed.feed.pk}
if settings.DEBUG or check_fetch_status:
diff = datetime.datetime.utcnow()-start
timediff = float("%s.%.2s" % (diff.seconds, (diff.microseconds / 1000)))
logging.user(request, "~FBRefreshing %s feeds (%s seconds) (%s/%s)" % (
len(feeds.keys()), timediff, check_fetch_status, len(favicons_fetching)))
return {'feeds': feeds}