Switched json parser to improve encoding/decoding times.
This commit is contained in:
parent
c61cd505af
commit
836fa49b0d
@ -1,12 +1,7 @@
|
||||
Flask==0.10.1
|
||||
Flask-Login==0.3.1
|
||||
Flask-SQLAlchemy==2.0
|
||||
Flask-WTF==0.12
|
||||
itsdangerous==0.24
|
||||
Jinja2==2.8
|
||||
MarkupSafe==0.23
|
||||
requests==2.8.0
|
||||
SQLAlchemy==1.0.8
|
||||
Werkzeug==0.10.4
|
||||
wheel==0.24.0
|
||||
WTForms==2.0.2
|
||||
requests
|
||||
wtforms
|
||||
flask
|
||||
flask-login
|
||||
flask-sqlalchemy
|
||||
flask-wtf
|
||||
ujson
|
@ -1,4 +1,4 @@
|
||||
import json
|
||||
import ujson as json
|
||||
import re
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
@ -62,7 +62,7 @@ class User(db.Model):
|
||||
self.username = data['user_information']['username']
|
||||
self.gravatar = data['user_information']['gravatar']
|
||||
if data.get('requested_information'):
|
||||
self.radicals = json.dumps(data['requested_information'])
|
||||
self.radicals = json.dumps(data['requested_information'], ensure_ascii=False)
|
||||
|
||||
def parse_kanji(self):
|
||||
response = requests.get("https://www.wanikani.com/api/user/" + self.api_key + "/kanji/")
|
||||
@ -71,7 +71,7 @@ class User(db.Model):
|
||||
if data.get('error'):
|
||||
raise ValueError(data['error']['message'])
|
||||
if data.get('requested_information'):
|
||||
self.kanji = json.dumps(data['requested_information'])
|
||||
self.kanji = json.dumps(data['requested_information'], ensure_ascii=False)
|
||||
|
||||
def parse_vocabulary(self):
|
||||
response = requests.get("https://www.wanikani.com/api/user/" + self.api_key + "/vocabulary/")
|
||||
@ -80,7 +80,7 @@ class User(db.Model):
|
||||
if data.get('error'):
|
||||
raise ValueError(data['error']['message'])
|
||||
if data.get('requested_information'):
|
||||
self.vocabulary = json.dumps(data['requested_information']['general'])
|
||||
self.vocabulary = json.dumps(data['requested_information']['general'], ensure_ascii=False)
|
||||
|
||||
def update_all(self):
|
||||
if (datetime.utcnow() - self.last_updated) > timedelta(hours=1):
|
||||
|
Loading…
Reference in New Issue
Block a user