mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Merge branch 'master' of github.com:samuelclay/NewsBlur into mongo
This commit is contained in:
commit
b1dfdb1239
5 changed files with 17 additions and 9 deletions
|
@ -212,11 +212,16 @@ def load_single_feed(request):
|
||||||
feed = Feed.objects.get(id=feed_id)
|
feed = Feed.objects.get(id=feed_id)
|
||||||
force_update = request.GET.get('force_update', False)
|
force_update = request.GET.get('force_update', False)
|
||||||
|
|
||||||
|
now = datetime.datetime.now()
|
||||||
|
logging.info(" ---> [%s] Loading feed #1: %s" % (request.user, feed.feed_title))
|
||||||
|
|
||||||
stories = feed.get_stories(offset, limit)
|
stories = feed.get_stories(offset, limit)
|
||||||
|
|
||||||
if force_update:
|
if force_update:
|
||||||
feed.update(force_update)
|
feed.update(force_update)
|
||||||
|
|
||||||
|
logging.info(" ---> [%s] Loading feed #2: %s" % (request.user, datetime.datetime.now()-now))
|
||||||
|
|
||||||
# Get intelligence classifier for user
|
# Get intelligence classifier for user
|
||||||
classifier_feeds = ClassifierFeed.objects.filter(user=user, feed=feed)
|
classifier_feeds = ClassifierFeed.objects.filter(user=user, feed=feed)
|
||||||
classifier_authors = ClassifierAuthor.objects.filter(user=user, feed=feed)
|
classifier_authors = ClassifierAuthor.objects.filter(user=user, feed=feed)
|
||||||
|
@ -230,8 +235,9 @@ def load_single_feed(request):
|
||||||
logging.info(" ***> [%s] UserSub DNE, creating: %s" % (user, feed))
|
logging.info(" ***> [%s] UserSub DNE, creating: %s" % (user, feed))
|
||||||
usersub = UserSubscription.objects.create(user=user, feed=feed)
|
usersub = UserSubscription.objects.create(user=user, feed=feed)
|
||||||
|
|
||||||
logging.info(" ---> [%s] Loading feed: %s" % (request.user, feed.feed_title))
|
|
||||||
|
logging.info(" ---> [%s] Loading feed #3: %s" % (request.user, datetime.datetime.now()-now))
|
||||||
|
|
||||||
if stories:
|
if stories:
|
||||||
last_read_date = stories[-1]['story_date']
|
last_read_date = stories[-1]['story_date']
|
||||||
else:
|
else:
|
||||||
|
@ -258,6 +264,7 @@ def load_single_feed(request):
|
||||||
'title': apply_classifier_titles(classifier_titles, story),
|
'title': apply_classifier_titles(classifier_titles, story),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logging.info(" ---> [%s] Loading feed #4: %s" % (request.user, datetime.datetime.now()-now))
|
||||||
# Intelligence
|
# Intelligence
|
||||||
|
|
||||||
feed_tags = json.decode(feed.popular_tags) if feed.popular_tags else []
|
feed_tags = json.decode(feed.popular_tags) if feed.popular_tags else []
|
||||||
|
@ -268,6 +275,8 @@ def load_single_feed(request):
|
||||||
usersub.feed_opens += 1
|
usersub.feed_opens += 1
|
||||||
usersub.save()
|
usersub.save()
|
||||||
|
|
||||||
|
logging.info(" ---> [%s] Loading feed #5: %s" % (request.user, datetime.datetime.now()-now))
|
||||||
|
|
||||||
data = dict(stories=stories,
|
data = dict(stories=stories,
|
||||||
feed_tags=feed_tags,
|
feed_tags=feed_tags,
|
||||||
feed_authors=feed_authors,
|
feed_authors=feed_authors,
|
||||||
|
|
|
@ -7,8 +7,8 @@ import re
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
option_list = BaseCommand.option_list + (
|
option_list = BaseCommand.option_list + (
|
||||||
make_option("-a", "--all", dest="all", action="store_true", help="All feeds [for a user, or everybody]"),
|
make_option("-a", "--all", dest="all", action="store_true", help="All feeds, need it or not (can be combined with a user)"),
|
||||||
make_option("-s", "--silent", dest="silent", action="store_true", help="Inverse verbosity."),
|
make_option("-s", "--silent", dest="silent", default=False, action="store_true", help="Inverse verbosity."),
|
||||||
make_option("-u", "--user", dest="user", nargs=1, help="Specify user id or username"),
|
make_option("-u", "--user", dest="user", nargs=1, help="Specify user id or username"),
|
||||||
make_option("-d", "--daemon", dest="daemonize", action="store_true"),
|
make_option("-d", "--daemon", dest="daemonize", action="store_true"),
|
||||||
)
|
)
|
||||||
|
|
|
@ -200,7 +200,7 @@ class Feed(models.Model):
|
||||||
def add_feed(self, feed_address, feed_link, feed_title):
|
def add_feed(self, feed_address, feed_link, feed_title):
|
||||||
print locals()
|
print locals()
|
||||||
|
|
||||||
def update(self, force=False, feed=None, single_threaded=False):
|
def update(self, force=False, feed=None, single_threaded=True):
|
||||||
from utils import feed_fetcher
|
from utils import feed_fetcher
|
||||||
try:
|
try:
|
||||||
self.feed_address = self.feed_address % {'NEWSBLUR_DIR': settings.NEWSBLUR_DIR}
|
self.feed_address = self.feed_address % {'NEWSBLUR_DIR': settings.NEWSBLUR_DIR}
|
||||||
|
@ -522,7 +522,7 @@ class Feed(models.Model):
|
||||||
total, random_factor = self.get_next_scheduled_update()
|
total, random_factor = self.get_next_scheduled_update()
|
||||||
|
|
||||||
next_scheduled_update = datetime.datetime.now() + datetime.timedelta(
|
next_scheduled_update = datetime.datetime.now() + datetime.timedelta(
|
||||||
minutes = total + random_factor)
|
minutes = int(total + random_factor))
|
||||||
|
|
||||||
self.next_scheduled_update = next_scheduled_update
|
self.next_scheduled_update = next_scheduled_update
|
||||||
|
|
||||||
|
|
|
@ -393,7 +393,7 @@ a img {
|
||||||
#feed_list .feed.NB-feed-unfetched {
|
#feed_list .feed.NB-feed-unfetched {
|
||||||
}
|
}
|
||||||
|
|
||||||
#feed_list .feed.NB-feed-exception .feed_count {
|
#feed_list .feed.NB-feed-exception .feed_counts {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -245,7 +245,6 @@ class Dispatcher:
|
||||||
db = pymongo.Connection(host=MONGO_DB['HOST'], port=MONGO_DB['PORT'])[MONGO_DB['NAME']]
|
db = pymongo.Connection(host=MONGO_DB['HOST'], port=MONGO_DB['PORT'])[MONGO_DB['NAME']]
|
||||||
|
|
||||||
current_process = multiprocessing.current_process()
|
current_process = multiprocessing.current_process()
|
||||||
lock = multiprocessing.Lock()
|
|
||||||
|
|
||||||
identity = "X"
|
identity = "X"
|
||||||
if current_process._identity:
|
if current_process._identity:
|
||||||
|
@ -259,7 +258,7 @@ class Dispatcher:
|
||||||
}
|
}
|
||||||
start_time = datetime.datetime.now()
|
start_time = datetime.datetime.now()
|
||||||
|
|
||||||
feed.set_next_scheduled_update(lock=lock)
|
feed.set_next_scheduled_update()
|
||||||
|
|
||||||
### Uncomment to test feed fetcher
|
### Uncomment to test feed fetcher
|
||||||
# from random import randint
|
# from random import randint
|
||||||
|
|
Loading…
Add table
Reference in a new issue