Switched json parser to improve encoding/decoding times.

This commit is contained in:
neviyn 2015-12-24 00:39:52 +00:00
parent c61cd505af
commit 836fa49b0d
2 changed files with 11 additions and 16 deletions

View File

@ -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

View File

@ -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):