forked from tanner/qotnews
Remove keys of uncached stories
This commit is contained in:
parent
b3d2eeb67f
commit
7b31fcf690
|
@ -42,11 +42,8 @@ with shelve.open(DATA_FILE) as db:
|
||||||
nid = news_ref_to_id[ref]
|
nid = news_ref_to_id[ref]
|
||||||
_ = news_cache[nid]
|
_ = news_cache[nid]
|
||||||
except KeyError as e:
|
except KeyError as e:
|
||||||
logging.error('Unable to find key: ' + str(e))
|
logging.error('Unable to find key {}. Trying to remove...'.format(str(e)))
|
||||||
logging.info('Clearing caches...')
|
news_list.remove(str(e))
|
||||||
news_list = []
|
|
||||||
news_ref_to_id = {}
|
|
||||||
news_cache = {}
|
|
||||||
|
|
||||||
def get_story(sid):
|
def get_story(sid):
|
||||||
if sid in news_cache:
|
if sid in news_cache:
|
||||||
|
@ -73,7 +70,12 @@ cors = CORS(flask_app)
|
||||||
|
|
||||||
@flask_app.route('/api')
|
@flask_app.route('/api')
|
||||||
def api():
|
def api():
|
||||||
|
try:
|
||||||
front_page = [news_cache[news_ref_to_id[ref]] for ref in news_list]
|
front_page = [news_cache[news_ref_to_id[ref]] for ref in news_list]
|
||||||
|
except KeyError as e:
|
||||||
|
logging.error('Unable to find key {}. Trying to remove...'.format(str(e)))
|
||||||
|
news_list.remove(str(e))
|
||||||
|
|
||||||
front_page = [copy.copy(x) for x in front_page if 'title' in x and x['title']]
|
front_page = [copy.copy(x) for x in front_page if 'title' in x and x['title']]
|
||||||
front_page = front_page[:60]
|
front_page = front_page[:60]
|
||||||
for story in front_page:
|
for story in front_page:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user