mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Handling edge cases for tags.
This commit is contained in:
parent
13611a9dfd
commit
d2b12da53a
5 changed files with 6 additions and 68 deletions
|
@ -112,7 +112,7 @@ def apply_classifier_authors(classifiers, story):
|
|||
|
||||
def apply_classifier_tags(classifiers, story):
|
||||
for classifier in classifiers:
|
||||
if story['story_tags'] and classifier.tag.name in json.decode(story['story_tags']):
|
||||
if story['story_tags'] and classifier.tag.name in story['story_tags']:
|
||||
# print 'Tags: (%s) %s -- %s' % (classifier.tag.name in story['story_tags'], classifier.tag.name, story['story_tags'])
|
||||
return classifier.score
|
||||
return 0
|
||||
|
|
|
@ -31,25 +31,7 @@ class UserSubscription(models.Model):
|
|||
|
||||
def get_user_feeds(self):
|
||||
return Feed.objects.get(user=self.user, feed=feeds)
|
||||
|
||||
def count_unread(self):
|
||||
if self.unread_count_updated > self.feed.last_update:
|
||||
return self.unread_count
|
||||
|
||||
count = (self.stories_newer_lastread()
|
||||
+ self.stories_between_lastread_allread())
|
||||
if count == 0:
|
||||
self.mark_read_date = datetime.datetime.now()
|
||||
self.last_read_date = datetime.datetime.now()
|
||||
self.unread_count_updated = datetime.datetime.now()
|
||||
self.unread_count = 0
|
||||
self.save()
|
||||
else:
|
||||
self.unread_count = count
|
||||
self.unread_count_updated = datetime.datetime.now()
|
||||
self.save()
|
||||
return count
|
||||
|
||||
|
||||
def mark_read(self):
|
||||
self.last_read_date = datetime.datetime.now()
|
||||
self.unread_count -= 1
|
||||
|
|
|
@ -32,7 +32,4 @@ class Command(BaseCommand):
|
|||
feed.update(True)
|
||||
usersubs = UserSubscription.objects.filter(
|
||||
feed=feed.id
|
||||
)
|
||||
for us in usersubs:
|
||||
us.count_unread()
|
||||
cache.delete('usersub:%s' % us.user_id)
|
||||
)
|
|
@ -201,7 +201,7 @@ class Feed(models.Model):
|
|||
for story_db in stories_db:
|
||||
story = {}
|
||||
# story_tags = story_db.tags.all()
|
||||
story['story_tags'] = story_db.story_tags
|
||||
story['story_tags'] = (story_db.story_tags and json.decode(story_db.story_tags)) or []
|
||||
story['short_parsed_date'] = format_story_link_date__short(story_db.story_date)
|
||||
story['long_parsed_date'] = format_story_link_date__long(story_db.story_date)
|
||||
story['story_date'] = story_db.story_date
|
||||
|
@ -209,7 +209,7 @@ class Feed(models.Model):
|
|||
story['story_title'] = story_db.story_title
|
||||
story['story_content'] = story_db.story_content
|
||||
story['story_permalink'] = story_db.story_permalink
|
||||
story['story_feed_id'] = self
|
||||
story['story_feed_id'] = self.pk
|
||||
story['id'] = story_db.id
|
||||
|
||||
stories.append(story)
|
||||
|
|
43
settings.py
43
settings.py
|
@ -57,49 +57,8 @@ logging.basicConfig(level=logging.INFO,
|
|||
filename=LOG_FILE,
|
||||
filemode='w')
|
||||
|
||||
if PRODUCTION:
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'NAME': 'newsblur',
|
||||
'ENGINE': 'django.db.backends.mysql',
|
||||
'USER': 'newsblur',
|
||||
'PASSWORD': '',
|
||||
'HOST': '127.0.0.1'
|
||||
}
|
||||
}
|
||||
# Absolute path to the directory that holds media.
|
||||
# Example: "/Users/media/media.lawrence.com/"
|
||||
MEDIA_URL = 'http://www.newsblur.com/media/'
|
||||
DEBUG = False
|
||||
CACHE_BACKEND = 'memcached://127.0.0.1:11211'
|
||||
logging.basicConfig(level=logging.INFO,
|
||||
format='%(asctime)s %(levelname)s %(message)s',
|
||||
filename=LOG_FILE,
|
||||
filemode='w')
|
||||
PREPEND_WWW = True
|
||||
elif STAGING:
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'NAME': 'newsblur',
|
||||
'ENGINE': 'django.db.backends.mysql',
|
||||
'USER': 'newsblur',
|
||||
'PASSWORD': '',
|
||||
'HOST': '127.0.0.1'
|
||||
}
|
||||
}
|
||||
DATABASE_HOST = 'localhost'
|
||||
DATABASE_PORT = ''
|
||||
|
||||
# Absolute path to the directory that holds media.
|
||||
# Example: "/Users/media/media.lawrence.com/"
|
||||
MEDIA_URL = '/media/'
|
||||
DEBUG = True
|
||||
CACHE_BACKEND = 'file:///var/tmp/django_cache'
|
||||
logging.basicConfig(level=logging.DEBUG,
|
||||
format='%(asctime)s %(levelname)s %(message)s',
|
||||
filename=LOG_FILE,
|
||||
filemode='w')
|
||||
elif DEV_SERVER2:
|
||||
if DEV_SERVER2:
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'NAME': 'newsblur',
|
||||
|
|
Loading…
Add table
Reference in a new issue