Permalink
Browse files

Adding update_counts to /feeds API endpoint, to force a recalculation…

… of feed unread counts (WARNING: slower than calling /feeds then /refresh_feeds).
  • Loading branch information...
1 parent 7c92c92 commit 936774b654ab95b32308b8a61a5c09cc4eb27ed4 @samuelclay committed Nov 7, 2011
Showing with 15 additions and 3 deletions.
  1. +3 −0 apps/reader/views.py
  2. +2 −2 media/js/newsblur/reader.js
  3. +1 −1 settings.py
  4. +9 −0 templates/static/api.yml
View
@@ -159,6 +159,7 @@ def load_feeds(request):
not_yet_fetched = False
include_favicons = request.REQUEST.get('include_favicons', False)
flat = request.REQUEST.get('flat', False)
+ update_counts = request.REQUEST.get('update_counts', False)
if flat: return load_feeds_flat(request)
@@ -175,6 +176,8 @@ def load_feeds(request):
for sub in user_subs:
pk = sub.feed.pk
+ if update_counts:
+ sub.calculate_feed_scores(silent=True)
feeds[pk] = sub.canonical(include_favicon=include_favicons)
if feeds[pk].get('not_yet_fetched'):
not_yet_fetched = True
@@ -4933,8 +4933,8 @@
this.model.save_exception_retry(feed_id, _.bind(this.force_feed_refresh, this, feed_id, $feed));
},
- setup_socket_realtime_unread_counts: function() {
- if (!this.socket && NEWSBLUR.Globals.is_premium && NEWSBLUR.Globals.username == 'samuel') {
+ setup_socket_realtime_unread_counts: function(force) {
+ if (force && !this.socket) {
this.socket = this.socket || io.connect('http://' + window.location.hostname + ':8888');
// this.socket.refresh_feeds = _.debounce(_.bind(this.force_feeds_refresh, this), 1000*10);
View
@@ -183,7 +183,7 @@
'js/jquery.fieldselection.js',
'js/jquery.flot.js',
'js/jquery.tipsy.js',
- 'js/socket.io-client.0.8.7.js',
+ # 'js/socket.io-client.0.8.7.js',
'js/underscore.js',
'js/underscore.string.js',
'js/newsblur/reader_utils.js',
View
@@ -84,6 +84,15 @@
optional: true
default: "false"
example: "true/false"
+ - key: update_counts
+ desc: >
+ Forces recalculation of unread counts on all feeds. The preferred method is
+ to call this endpoint without updated counts, then call refresh_feeds to get
+ updated counts. That way you can quickly show the user's feeds, then update
+ the counts. Turning this option on will lead to a slower load-time.
+ optional: true
+ default: "false"
+ example: "true/false"
- url: /reader/favicons
method: GET

0 comments on commit 936774b

Please sign in to comment.