From ff19b0e6b95422c28431314f4c3410bccf9c8473 Mon Sep 17 00:00:00 2001 From: Nathan Cannon Date: Sun, 11 Oct 2015 22:46:07 +0100 Subject: [PATCH] Updated response logic to filter only burned items now that database includes non-burned items. --- wanikaniburned.py | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/wanikaniburned.py b/wanikaniburned.py index efea733..a433aef 100644 --- a/wanikaniburned.py +++ b/wanikaniburned.py @@ -134,28 +134,31 @@ def get_items(): items = [] radical_count = 0 for item in json.loads(current_user.radicals): - radical_count += 1 - if item['image']: - items.append({'item_type': 'radical', 'question': item['image'], 'answer': item['meaning']}) - else: - items.append({'item_type': 'radical', 'question': item['character'], 'answer': item['meaning']}) + if item['user_specific'] and item['user_specific']['burned']: + radical_count += 1 + if item['image']: + items.append({'item_type': 'radical', 'question': item['image'], 'answer': item['meaning']}) + else: + items.append({'item_type': 'radical', 'question': item['character'], 'answer': item['meaning']}) kanji_count = 0 for item in json.loads(current_user.kanji): kanji_count += 1 made_answer = "" - if item['onyomi'] and item['kunyomi']: - made_answer = item['onyomi'] + ',' + item['kunyomi'].replace('.*', '') - elif item['onyomi']: - made_answer = item['onyomi'] - elif item['kunyomi']: - made_answer = item['kunyomi'].replace('.*', '') - items.append({'item_type': 'kanji', 'question': item['character'], 'answer': made_answer, - 'answer_meaning': item['meaning']}) + if item['user_specific'] and item['user_specific']['burned']: + if item['onyomi'] and item['kunyomi']: + made_answer = item['onyomi'] + ',' + item['kunyomi'].replace('.*', '') + elif item['onyomi']: + made_answer = item['onyomi'] + elif item['kunyomi']: + made_answer = item['kunyomi'].replace('.*', '') + items.append({'item_type': 'kanji', 'question': item['character'], 'answer': made_answer, + 'answer_meaning': item['meaning']}) vocabulary_count = 0 for item in json.loads(current_user.vocabulary): - vocabulary_count += 1 - items.append({'item_type': 'vocabulary', 'question': item['character'], 'answer': item['kana'], - 'answer_meaning': item['meaning']}) + if item['user_specific'] and item['user_specific']['burned']: + vocabulary_count += 1 + items.append({'item_type': 'vocabulary', 'question': item['character'], 'answer': item['kana'], + 'answer_meaning': item['meaning']}) return jsonify(radical_count=radical_count, kanji_count=kanji_count, vocabulary_count=vocabulary_count, item_list=items)