Faster feed refreshing (insta-fetching) by only computing the score for the current user and leaving the other users with dirty subscriptions.

This commit is contained in:
Samuel Clay 2010-11-10 18:04:17 -05:00
parent 21379537aa
commit fa663e910a
6 changed files with 63 additions and 60 deletions

View file

@ -51,6 +51,8 @@ class Command(BaseCommand):
if options['single_threaded']:
num_workers = 1
options['compute_scores'] = True
disp = feed_fetcher.Dispatcher(options, num_workers)
feeds_queue = []

View file

@ -297,7 +297,7 @@ class Feed(models.Model):
self.save()
def update(self, force=False, single_threaded=True):
def update(self, force=False, single_threaded=True, compute_scores=True):
from utils import feed_fetcher
try:
self.feed_address = self.feed_address % {'NEWSBLUR_DIR': settings.NEWSBLUR_DIR}
@ -311,6 +311,7 @@ class Feed(models.Model):
'timeout': 10,
'single_threaded': single_threaded,
'force': force,
'compute_scores': compute_scores,
}
disp = feed_fetcher.Dispatcher(options, 1)
disp.add_jobs([[self.pk]])

View file

@ -4,6 +4,7 @@ from django.shortcuts import get_object_or_404
from django.http import HttpResponseForbidden
from django.db import IntegrityError
from apps.rss_feeds.models import Feed, merge_feeds
from apps.reader.models import UserSubscription
from utils.user_functions import ajax_login_required
from utils import json_functions as json, feedfinder
from utils.feed_functions import relative_timeuntil, relative_timesince
@ -58,7 +59,9 @@ def exception_retry(request):
feed.fetched_once = True
feed.save()
feed.update(force=True)
feed.update(force=True, compute_scores=False)
usersub = UserSubscription.objects.get(user=request.user, feed=feed)
usersub.calculate_feed_scores(silent=False)
return {'code': 1}

View file

@ -304,6 +304,8 @@
<key>Layout</key>
<array>
<dict>
<key>BecomeActive</key>
<true/>
<key>ContentConfiguration</key>
<dict>
<key>PBXBottomSmartGroupGIDs</key>
@ -346,7 +348,7 @@
<key>PBXSmartGroupTreeModuleOutlineStateSelectionKey</key>
<array>
<array>
<integer>19</integer>
<integer>18</integer>
<integer>1</integer>
<integer>0</integer>
</array>
@ -382,14 +384,12 @@
<key>Dock</key>
<array>
<dict>
<key>BecomeActive</key>
<true/>
<key>ContentConfiguration</key>
<dict>
<key>PBXProjectModuleGUID</key>
<string>1CE0B20306471E060097A5F4</string>
<key>PBXProjectModuleLabel</key>
<string>LoginViewController.m</string>
<string>LoginViewController.h</string>
<key>PBXSplitModuleInNavigatorKey</key>
<dict>
<key>Split0</key>
@ -397,11 +397,11 @@
<key>PBXProjectModuleGUID</key>
<string>1CE0B20406471E060097A5F4</string>
<key>PBXProjectModuleLabel</key>
<string>LoginViewController.m</string>
<string>LoginViewController.h</string>
<key>_historyCapacity</key>
<integer>0</integer>
<key>bookmark</key>
<string>78E69EEE127E650C00AB2B15</string>
<string>78BC27C8128AEFBC00D7A26E</string>
<key>history</key>
<array>
<string>787A0E8411CEAF200056422D</string>
@ -421,9 +421,9 @@
<string>784B514C127E44C3008F90EA</string>
<string>784B514D127E44C3008F90EA</string>
<string>78E69EEA127E650C00AB2B15</string>
<string>78E69EEB127E650C00AB2B15</string>
<string>78E69EEC127E650C00AB2B15</string>
<string>78E69EED127E650C00AB2B15</string>
<string>78BC27C2128AEBEA00D7A26E</string>
<string>78BC27C3128AEBEA00D7A26E</string>
</array>
</dict>
<key>SplitCount</key>
@ -435,14 +435,14 @@
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
<string>{{0, 0}, {735, 568}}</string>
<string>{{0, 0}, {735, 564}}</string>
<key>RubberWindowFrame</key>
<string>260 110 1034 767 0 0 1440 878 </string>
</dict>
<key>Module</key>
<string>PBXNavigatorGroup</string>
<key>Proportion</key>
<string>568pt</string>
<string>564pt</string>
</dict>
<dict>
<key>ContentConfiguration</key>
@ -455,14 +455,14 @@
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
<string>{{0, 573}, {735, 153}}</string>
<string>{{0, 569}, {735, 157}}</string>
<key>RubberWindowFrame</key>
<string>260 110 1034 767 0 0 1440 878 </string>
</dict>
<key>Module</key>
<string>XCDetailModule</string>
<key>Proportion</key>
<string>153pt</string>
<string>157pt</string>
</dict>
</array>
<key>Proportion</key>
@ -481,9 +481,9 @@
</array>
<key>TableOfContents</key>
<array>
<string>78E69ED5127E639C00AB2B15</string>
<string>78BC27C5128AEBEA00D7A26E</string>
<string>1CE0B1FE06471DED0097A5F4</string>
<string>78E69ED6127E639C00AB2B15</string>
<string>78BC27C6128AEBEA00D7A26E</string>
<string>1CE0B20306471E060097A5F4</string>
<string>1CE0B20506471E060097A5F4</string>
</array>
@ -618,7 +618,7 @@
<key>StatusbarIsVisible</key>
<true/>
<key>TimeStamp</key>
<real>310273292.80610299</real>
<real>311095228.47693199</real>
<key>ToolbarConfigUserDefaultsMinorVersion</key>
<string>2</string>
<key>ToolbarDisplayMode</key>
@ -635,10 +635,8 @@
<integer>5</integer>
<key>WindowOrderList</key>
<array>
<string>1CD10A99069EF8BA00B06720</string>
<string>788997AE11C9C87C00041675</string>
<string>/Users/conesus/newsblur/media/iphone/NewsBlur.xcodeproj</string>
<string>1C78EAAD065D492600B07095</string>
</array>
<key>WindowString</key>
<string>260 110 1034 767 0 0 1440 878 </string>
@ -679,8 +677,6 @@
<string>251pt</string>
</dict>
<dict>
<key>BecomeActive</key>
<true/>
<key>ContentConfiguration</key>
<dict>
<key>PBXProjectModuleGUID</key>
@ -720,7 +716,7 @@
<key>TableOfContents</key>
<array>
<string>788997AE11C9C87C00041675</string>
<string>78E69ED3127E639C00AB2B15</string>
<string>78BC27C7128AEBEA00D7A26E</string>
<string>1CD0528F0623707200166675</string>
<string>XCMainBuildResultsModuleGUID</string>
</array>

View file

@ -134,8 +134,8 @@
PBXFileDataSource_Warnings_ColumnID,
);
};
PBXPerProjectTemplateStateSaveDate = 310272920;
PBXWorkspaceStateSaveDate = 310272920;
PBXPerProjectTemplateStateSaveDate = 311094236;
PBXWorkspaceStateSaveDate = 311094236;
};
perUserProjectItems = {
7842EB9911CFFC1B0066CF9D /* PBXTextBookmark */ = 7842EB9911CFFC1B0066CF9D /* PBXTextBookmark */;
@ -154,11 +154,11 @@
784B514D127E44C3008F90EA /* PBXTextBookmark */ = 784B514D127E44C3008F90EA /* PBXTextBookmark */;
785086B412089C6000CF3B50 /* PBXTextBookmark */ = 785086B412089C6000CF3B50 /* PBXTextBookmark */;
787A0E8411CEAF200056422D /* PBXTextBookmark */ = 787A0E8411CEAF200056422D /* PBXTextBookmark */;
78BC27C2128AEBEA00D7A26E /* PBXTextBookmark */ = 78BC27C2128AEBEA00D7A26E /* PBXTextBookmark */;
78BC27C3128AEBEA00D7A26E /* PBXTextBookmark */ = 78BC27C3128AEBEA00D7A26E /* PBXTextBookmark */;
78BC27C8128AEFBC00D7A26E /* PBXTextBookmark */ = 78BC27C8128AEFBC00D7A26E /* PBXTextBookmark */;
78E69EEA127E650C00AB2B15 /* PBXTextBookmark */ = 78E69EEA127E650C00AB2B15 /* PBXTextBookmark */;
78E69EEB127E650C00AB2B15 /* PBXTextBookmark */ = 78E69EEB127E650C00AB2B15 /* PBXTextBookmark */;
78E69EEC127E650C00AB2B15 /* PBXTextBookmark */ = 78E69EEC127E650C00AB2B15 /* PBXTextBookmark */;
78E69EED127E650C00AB2B15 /* PBXTextBookmark */ = 78E69EED127E650C00AB2B15 /* PBXTextBookmark */;
78E69EEE127E650C00AB2B15 /* PBXTextBookmark */ = 78E69EEE127E650C00AB2B15 /* PBXTextBookmark */;
};
sourceControlManager = 788997A911C9C3F000041675 /* Source Control */;
userBuildSettings = {
@ -279,7 +279,7 @@
};
784B50EA127E3F68008F90EA /* LoginViewController.h */ = {
uiCtxt = {
sepNavIntBoundsRect = "{{0, 0}, {686, 528}}";
sepNavIntBoundsRect = "{{0, 0}, {686, 547}}";
sepNavSelRange = "{489, 17}";
sepNavVisRange = "{0, 585}";
sepNavWindowFrame = "{{72, 315}, {750, 558}}";
@ -289,7 +289,7 @@
uiCtxt = {
sepNavIntBoundsRect = "{{0, 0}, {686, 715}}";
sepNavSelRange = "{739, 0}";
sepNavVisRange = "{200, 977}";
sepNavVisRange = "{0, 1059}";
sepNavWindowFrame = "{{72, 315}, {750, 558}}";
};
};
@ -465,6 +465,36 @@
isa = PBXCodeSenseManager;
indexTemplatePath = "";
};
78BC27C2128AEBEA00D7A26E /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 784B50EB127E3F68008F90EA /* LoginViewController.m */;
name = "LoginViewController.m: 29";
rLen = 0;
rLoc = 739;
rType = 0;
vrLen = 1059;
vrLoc = 0;
};
78BC27C3128AEBEA00D7A26E /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 784B50EA127E3F68008F90EA /* LoginViewController.h */;
name = "LoginViewController.h: 22";
rLen = 17;
rLoc = 489;
rType = 0;
vrLen = 585;
vrLoc = 0;
};
78BC27C8128AEFBC00D7A26E /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 784B50EA127E3F68008F90EA /* LoginViewController.h */;
name = "LoginViewController.h: 22";
rLen = 17;
rLoc = 489;
rType = 0;
vrLen = 585;
vrLoc = 0;
};
78E69EEA127E650C00AB2B15 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 28D7ACF70DDB3853001CB0EB /* NewsBlurViewController.m */;
@ -475,16 +505,6 @@
vrLen = 1458;
vrLoc = 2175;
};
78E69EEB127E650C00AB2B15 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 784B50EA127E3F68008F90EA /* LoginViewController.h */;
name = "LoginViewController.h: 22";
rLen = 17;
rLoc = 489;
rType = 0;
vrLen = 585;
vrLoc = 0;
};
78E69EEC127E650C00AB2B15 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 1D3623250D0F684500981E51 /* NewsBlurAppDelegate.m */;
@ -495,26 +515,6 @@
vrLen = 1275;
vrLoc = 84;
};
78E69EED127E650C00AB2B15 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 784B50EB127E3F68008F90EA /* LoginViewController.m */;
name = "LoginViewController.m: 29";
rLen = 0;
rLoc = 739;
rType = 0;
vrLen = 907;
vrLoc = 237;
};
78E69EEE127E650C00AB2B15 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 784B50EB127E3F68008F90EA /* LoginViewController.m */;
name = "LoginViewController.m: 29";
rLen = 0;
rLoc = 739;
rType = 0;
vrLen = 977;
vrLoc = 200;
};
78FC34EA11CA94900055C312 /* JSON.h */ = {
uiCtxt = {
sepNavIntBoundsRect = "{{0, 0}, {1143, 780}}";

View file

@ -286,6 +286,7 @@ class Dispatcher:
feed.save()
MUserStory.delete_old_stories(feed_id=feed.pk)
try:
if self.options['compute_scores']:
self.count_unreads_for_subscribers(feed)
except TimeoutError:
logging.debug(' ---> [%-30s] Unread count took too long...' % (unicode(feed)[:30],))