mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
Fixing broken unread count updater.
This commit is contained in:
parent
fab5539ffc
commit
b0898ce40d
2 changed files with 20 additions and 8 deletions
|
@ -684,6 +684,7 @@ class UserSubscription(models.Model):
|
|||
ont = self.unread_count_neutral
|
||||
ops = self.unread_count_positive
|
||||
oousd = self.oldest_unread_story_date
|
||||
ucu = self.unread_count_updated
|
||||
onur = self.needs_unread_recalc
|
||||
oit = self.is_trained
|
||||
|
||||
|
@ -791,6 +792,7 @@ class UserSubscription(models.Model):
|
|||
if self.unread_count_positive != ops: update_fields.append('unread_count_positive')
|
||||
if self.unread_count_neutral != ont: update_fields.append('unread_count_neutral')
|
||||
if self.unread_count_negative != ong: update_fields.append('unread_count_negative')
|
||||
if self.unread_count_updated != ucu: update_fields.append('unread_count_updated')
|
||||
if self.oldest_unread_story_date != oousd: update_fields.append('oldest_unread_story_date')
|
||||
if self.needs_unread_recalc != onur: update_fields.append('needs_unread_recalc')
|
||||
if self.is_trained != oit: update_fields.append('is_trained')
|
||||
|
|
|
@ -401,6 +401,7 @@ def load_feeds_flat(request):
|
|||
@never_cache
|
||||
@json.json_view
|
||||
def refresh_feeds(request):
|
||||
start = datetime.datetime.now()
|
||||
user = get_user(request)
|
||||
feed_ids = request.REQUEST.getlist('feed_id')
|
||||
check_fetch_status = request.REQUEST.get('check_fetch_status')
|
||||
|
@ -412,20 +413,21 @@ def refresh_feeds(request):
|
|||
if feed_ids or (not social_feed_ids and not feed_ids):
|
||||
feeds = UserSubscription.feeds_with_updated_counts(user, feed_ids=feed_ids,
|
||||
check_fetch_status=check_fetch_status)
|
||||
checkpoint1 = datetime.datetime.now()
|
||||
social_feeds = {}
|
||||
if social_feed_ids or (not social_feed_ids and not feed_ids):
|
||||
social_feeds = MSocialSubscription.feeds_with_updated_counts(user, social_feed_ids=social_feed_ids)
|
||||
checkpoint2 = datetime.datetime.now()
|
||||
|
||||
favicons_fetching = [int(f) for f in favicons_fetching if f]
|
||||
feed_icons = {}
|
||||
if favicons_fetching:
|
||||
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')
|
||||
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.filter(user=user, active=True).only('feed')
|
||||
sub_feed_ids = [s.feed_id for s in user_subs]
|
||||
|
@ -449,8 +451,16 @@ def refresh_feeds(request):
|
|||
interactions_count = MInteraction.user_unread_count(user.pk)
|
||||
|
||||
if True or settings.DEBUG or check_fetch_status:
|
||||
logging.user(request, "~FBRefreshing %s feeds (%s/%s)" % (
|
||||
len(feeds.keys()), check_fetch_status, len(favicons_fetching)))
|
||||
end = datetime.datetime.now()
|
||||
extra_fetch = ""
|
||||
if check_fetch_status or favicons_fetching:
|
||||
extra_fetch = "(%s/%s)" % (check_fetch_status, len(favicons_fetching))
|
||||
logging.user(request, "~FBRefreshing %s+%s feeds %s (%.4s/%.4s/%.4s)" % (
|
||||
len(feeds.keys()), len(social_feeds.keys()), extra_fetch,
|
||||
(checkpoint1-start).total_seconds(),
|
||||
(checkpoint2-start).total_seconds(),
|
||||
(end-start).total_seconds(),
|
||||
))
|
||||
|
||||
return {
|
||||
'feeds': feeds,
|
||||
|
|
Loading…
Add table
Reference in a new issue