yet another attempt to fix the scheduling bug
parent
8b115c98ad
commit
774d269d91
6
menu.py
6
menu.py
|
@ -17,7 +17,6 @@ def index():
|
|||
if 'user_id' in session:
|
||||
user_id = session['user_id']
|
||||
username = session['username']
|
||||
print(username)
|
||||
status = schedule_status(user_id)
|
||||
|
||||
user_settings = get_settings(user_id)
|
||||
|
@ -25,7 +24,7 @@ def index():
|
|||
max_due = int(user_settings["max_due"])
|
||||
|
||||
total_new = len(list_of_new_cards_by_ids(user_id))
|
||||
total_due = len(list_of_due_cards_by_ids(user_id)) - total_new
|
||||
total_due = len(list_of_due_cards_by_ids(user_id))
|
||||
rated_today_new = rated_today_by_staus("new", user_id)
|
||||
rated_today_due = rated_today_by_staus("due", user_id)
|
||||
remaining_new_today = remaining_items(max_new, total_new, rated_today_new)
|
||||
|
@ -33,13 +32,10 @@ def index():
|
|||
|
||||
if request.method == "POST":
|
||||
action = request.form.get("menu", False) #internetna rešitev, nevem kako, ampak dela, tj. dobi info iz meni buttonov
|
||||
print(action)
|
||||
if action == "new_session":
|
||||
#preverimo če so sploh karte v collectionu
|
||||
print("userID", user_id)
|
||||
c = dbsession.query(Card).filter(Card.owner_id == user_id).all()
|
||||
if c == []:
|
||||
print("ne najdem collectiona")
|
||||
return render_template("error/no_cards_in_collection.html", username=username)
|
||||
|
||||
return redirect(url_for("deck"))
|
||||
|
|
|
@ -70,13 +70,26 @@ def is_due(card_id):
|
|||
dbsession.close()
|
||||
return date.today() >= due_date
|
||||
|
||||
def is_new(card_id):
|
||||
dbsession = get_session()
|
||||
rating = dbsession.query(Rating).filter(Rating.card_id == card_id).first()
|
||||
dbsession.close()
|
||||
if rating == None:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
|
||||
def list_of_due_cards_by_ids(user_id):
|
||||
"this should not include new cards"
|
||||
dbsession = get_session()
|
||||
cards = dbsession.query(Card).filter(Card.owner_id == user_id).all()
|
||||
l = []
|
||||
for card in cards:
|
||||
if is_due(card.id):
|
||||
if is_new(card.id):
|
||||
pass
|
||||
elif is_due(card.id):
|
||||
l.append(card.id)
|
||||
dbsession.close()
|
||||
return l
|
||||
|
@ -158,7 +171,7 @@ def schedule_status(user_id):
|
|||
rated_due = rated_today_by_staus("due", user_id)
|
||||
|
||||
total_new = len(list_of_new_cards_by_ids(user_id))
|
||||
total_due = len(list_of_due_cards_by_ids(user_id)) - total_new
|
||||
total_due = len(list_of_due_cards_by_ids(user_id))
|
||||
|
||||
remaining_new_today = remaining_items(max_new, total_new, rated_new)
|
||||
remaining_due_today = remaining_items(max_due, total_due, rated_due)
|
||||
|
@ -222,7 +235,7 @@ def sr_session():
|
|||
max_due = int(user_settings["max_due"])
|
||||
|
||||
total_new = len(list_of_new_cards_by_ids(user_id))
|
||||
total_due = len(list_of_due_cards_by_ids(user_id)) - total_new
|
||||
total_due = len(list_of_due_cards_by_ids(user_id))
|
||||
|
||||
rated_today_new = rated_today_by_staus("new", user_id)
|
||||
rated_today_due = rated_today_by_staus("due", user_id)
|
||||
|
|
Loading…
Reference in New Issue