Added query element for /user_items to filter item srs state.
This commit is contained in:
parent
231b4231a3
commit
a907736895
@ -104,11 +104,11 @@ def parse_range(input_range):
|
||||
return result
|
||||
|
||||
|
||||
def get_items_with_level_restriction(level_range):
|
||||
def get_items_with_level_restriction(level_range, item_state):
|
||||
items = []
|
||||
radical_count = 0
|
||||
for item in json.loads(current_user.radicals):
|
||||
if item['user_specific'] and item['user_specific']['burned'] and item['level'] in level_range:
|
||||
if item['user_specific'] and item['user_specific']['srs'] in item_state and item['level'] in level_range:
|
||||
radical_count += 1
|
||||
if item['image']:
|
||||
items.append({'item_type': 'radical', 'question': item['image'], 'answer': item['meaning']})
|
||||
@ -117,7 +117,7 @@ def get_items_with_level_restriction(level_range):
|
||||
kanji_count = 0
|
||||
for item in json.loads(current_user.kanji):
|
||||
made_answer = ""
|
||||
if item['user_specific'] and item['user_specific']['burned'] and item['level'] in level_range:
|
||||
if item['user_specific'] and item['user_specific']['srs'] in item_state and item['level'] in level_range:
|
||||
kanji_count += 1
|
||||
if item['onyomi'] and item['kunyomi']:
|
||||
made_answer = item['onyomi'] + ',' + item['kunyomi'].replace('.*', '')
|
||||
@ -129,7 +129,7 @@ def get_items_with_level_restriction(level_range):
|
||||
'answer_meaning': item['meaning']})
|
||||
vocabulary_count = 0
|
||||
for item in json.loads(current_user.vocabulary):
|
||||
if item['user_specific'] and item['user_specific']['burned'] and item['level'] in level_range:
|
||||
if item['user_specific'] and item['user_specific']['srs'] in item_state and item['level'] in level_range:
|
||||
vocabulary_count += 1
|
||||
items.append({'item_type': 'vocabulary', 'question': item['character'], 'answer': item['kana'],
|
||||
'answer_meaning': item['meaning']})
|
||||
@ -184,7 +184,10 @@ def get_items():
|
||||
level_range = list(range(0, 61))
|
||||
if request.args.get('level_range'):
|
||||
level_range = parse_range(request.args.get('level_range'))
|
||||
return get_items_with_level_restriction(level_range)
|
||||
item_state = ['burned']
|
||||
if request.args.get('item_state'):
|
||||
item_state = request.args.get('item_state').split(',')
|
||||
return get_items_with_level_restriction(level_range, item_state)
|
||||
|
||||
|
||||
@app.route('/refresh', methods=['POST'])
|
||||
|
Loading…
Reference in New Issue
Block a user