mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Dashboard shouldnt truncate stories. Also handling missing elasticsearch more gracefully.
This commit is contained in:
parent
73c3a0242b
commit
fc69c0c8b9
2 changed files with 17 additions and 12 deletions
|
@ -1533,15 +1533,15 @@ def load_river_stories__redis(request):
|
|||
stories = new_stories
|
||||
|
||||
# Clean stories to remove potentially old stories on dashboard
|
||||
if initial_dashboard:
|
||||
new_stories = []
|
||||
now = datetime.datetime.utcnow()
|
||||
hour = now + datetime.timedelta(hours=1)
|
||||
month_ago = now - datetime.timedelta(days=settings.DAYS_OF_UNREAD)
|
||||
for story in stories:
|
||||
if story['story_date'] >= month_ago and story['story_date'] < hour:
|
||||
new_stories.append(story)
|
||||
stories = new_stories
|
||||
# if initial_dashboard:
|
||||
# new_stories = []
|
||||
# now = datetime.datetime.utcnow()
|
||||
# hour = now + datetime.timedelta(hours=1)
|
||||
# month_ago = now - datetime.timedelta(days=settings.DAYS_OF_UNREAD)
|
||||
# for story in stories:
|
||||
# if story['story_date'] >= month_ago and story['story_date'] < hour:
|
||||
# new_stories.append(story)
|
||||
# stories = new_stories
|
||||
|
||||
# if page > 1:
|
||||
# import random
|
||||
|
|
|
@ -3,7 +3,9 @@ import time
|
|||
import datetime
|
||||
import pymongo
|
||||
import pyelasticsearch
|
||||
import elasticsearch
|
||||
import redis
|
||||
import urllib3
|
||||
import celery
|
||||
import html
|
||||
import mongoengine as mongo
|
||||
|
@ -214,6 +216,9 @@ class SearchStory:
|
|||
logging.debug(" ---> ~FCCreating search index for ~FM%s" % cls.index_name())
|
||||
except pyelasticsearch.IndexAlreadyExistsError:
|
||||
return
|
||||
except (pyelasticsearch.ElasticHttpError, elasticsearch.exceptions.ConnectionError, urllib3.exceptions.NewConnectionError) as e:
|
||||
logging.debug(" ***> ~FRNo search server available for creating story mapping.")
|
||||
return
|
||||
|
||||
mapping = {
|
||||
'title': {
|
||||
|
@ -268,10 +273,10 @@ class SearchStory:
|
|||
}
|
||||
try:
|
||||
cls.ES().index(index=cls.index_name(), doc_type='story-type', doc=doc, id=story_hash)
|
||||
except pyelasticsearch.ElasticHttpError as e:
|
||||
except (pyelasticsearch.ElasticHttpError, elasticsearch.exceptions.ConnectionError, urllib3.exceptions.NewConnectionError) as e:
|
||||
logging.debug(" ***> ~FRNo search server available for story indexing.")
|
||||
if settings.DEBUG:
|
||||
raise e
|
||||
# if settings.DEBUG:
|
||||
# raise e
|
||||
|
||||
@classmethod
|
||||
def remove(cls, story_hash):
|
||||
|
|
Loading…
Add table
Reference in a new issue