File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3434from io import BytesIO
3535import zipfile
3636import cgi
37- import datetime
3837import uuid
3938import flask
4039import traceback
@@ -227,9 +226,12 @@ def plotusers():
227226 history_setting = ndb .Key ('Setting' , 'user_count_history' ).get ()
228227 if not history_setting or history_setting .value == 'NOT SET' :
229228 return flask .render_template ('plotusers.html' , points = [], updated = None , no_data = True )
230- history = json .loads (history_setting .value )
229+ try :
230+ history = json .loads (history_setting .value )
231+ except (json .JSONDecodeError , ValueError ):
232+ return flask .render_template ('plotusers.html' , points = [], updated = None , no_data = True )
231233 return flask .render_template ('plotusers.html' ,
232- points = history [ 'points' ] ,
234+ points = history . get ( 'points' , []) ,
233235 updated = history .get ('updated' ),
234236 no_data = False )
235237
@@ -250,6 +252,8 @@ def update_user_count():
250252 else :
251253 try :
252254 history = json .loads (history_setting .value )
255+ if 'points' not in history :
256+ history ['points' ] = []
253257 except (json .JSONDecodeError , ValueError ):
254258 history = {'points' : []}
255259
You can’t perform that action at this time.
0 commit comments