anoter attempt at fixing the scheduling bug

master
janko 2022-10-30 23:25:20 +01:00
parent 133da4c568
commit 94243b4f67
1 changed files with 20 additions and 9 deletions

View File

@ -1,4 +1,4 @@
from random import choice, choices
from random import choice
from datetime import date, timedelta
from flask import flash, session, redirect, url_for, request, render_template
from sqlalchemy import desc
@ -94,7 +94,6 @@ def list_of_new_cards_by_ids(user_id):
return l
#TODO sus ker ni user id?
def rated_today_by_staus (card_status, user_id):
"""
Returns number of cards rated today by user by status (new or due)
@ -156,10 +155,16 @@ def schedule_status(user_id):
max_today_new = min(max_new, scheduled_new+rated_new)
max_today_due = min(max_due, scheduled_due+rated_due)
print("max_new_today", max_today_new)
print("max_due_today", max_today_due)
"""print("SCHEDULE STATUS:\n ############################")
print("rated_due", rated_due)
print("rated_new", rated_new)
print("scheduled_due: ", scheduled_due)
print("scheduled_new: ", scheduled_new)
print("max_new_today", max_today_new)
print("max_due_today", max_today_due)"""
if max_today_due+max_today_new == rated_due+rated_new:
return "done"
@ -217,19 +222,25 @@ def sr_session():
dbsession.close()
user_settings = get_settings(user_id)
max_new = user_settings["max_new"]
max_due = user_settings["max_due"]
max_new = int(user_settings["max_new"])
max_due = int(user_settings["max_due"])
all_new = len(list_of_new_cards_by_ids(user_id))
all_due = len(list_of_due_cards_by_ids(user_id))
all_due = len(list_of_due_cards_by_ids(user_id)) - all_new
rated_today_new = rated_today_by_staus("new", user_id)
rated_today_due = rated_today_by_staus("due", user_id)
"""
print("max_due: ", max_due, " all_due", all_due)
print("max_new: ", max_new, " all_new", all_new)
print("rated_today_new: ", rated_today_new)
"""
#checks if there are any new/due cards left for today and gets the next one. max can be more than all scheduled, min decides which is the limt.
if min(int(max_new), all_new) - int(rated_today_new) > 0:
if min(max_new-rated_today_new, all_new) > 0:
new_card_id=get_a_card_by_status(user_id, "new")
elif min(int(max_due), all_due) - int(rated_today_due) > 0:
elif min(max_due-rated_today_due, all_due) > 0:
new_card_id=get_a_card_by_status(user_id, "due")
else:
dbsession.close()