File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4848from .models import User , Program , Folder , Setting
4949
5050import os , re , base64
51- from datetime import datetime
51+ from datetime import datetime , timezone
5252
5353# URI encoding (percent-escaping of all characters other than [A-Za-z0-9-_.~]) is used for names
5454# of users, folders and programs in the model and in URIs and in JSON, so no (un)escaping is required.
@@ -248,9 +248,12 @@ def update_user_count():
248248 elif history_setting .value == 'NOT SET' :
249249 history = {'points' : []}
250250 else :
251- history = json .loads (history_setting .value )
251+ try :
252+ history = json .loads (history_setting .value )
253+ except (json .JSONDecodeError , ValueError ):
254+ history = {'points' : []}
252255
253- now = datetime .utcnow ( )
256+ now = datetime .now ( timezone . utc )
254257 history ['updated' ] = now .strftime ('%Y-%m-%d' )
255258 history ['points' ].append ({'month' : now .strftime ('%Y-%m' ), 'count' : count })
256259
You can’t perform that action at this time.
0 commit comments