Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance Steps Statistics Display Logic #516

Merged
merged 1 commit into from
Dec 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ def get_steps_stats(self: CollectionStats):
learning_count = sum(1 for r in ratings.items() if r[0] != 0)

first_learning = True
not_enough_data = True
for rating, style in ratings.items():
stats = results["stats"].get(rating, {})
if not stats:
Expand Down Expand Up @@ -181,6 +182,7 @@ def get_steps_stats(self: CollectionStats):
</tr>"""
continue

not_enough_data = False
state_cell = ""
if rating == 0:
state_cell = '<td class="trl"><b>Relearning</b></td>'
Expand Down Expand Up @@ -210,7 +212,8 @@ def get_steps_stats(self: CollectionStats):
if stats["retention"] == 1 or stats["retention"] == 0 or stats["count"] < 100:
results["stability"][rating] = 86400

html += f"""
html += (
f"""
<tr>
<td colspan="12" class="trl">
<strong>Desired retention:</strong>
Expand Down Expand Up @@ -258,24 +261,29 @@ def get_steps_stats(self: CollectionStats):
}};

function calculateSteps() {{
const factor = calculateFactor(parseFloat(document.querySelector("#desired-retention").value));
const factor = calculateFactor(parseFloat(document.querySelector("#desired-retention").value));

const learningStep1 = calculateStep(stability[1], factor);
// hardStep = (2 * stability[2] - stability[1]) * factor
// goodStep = stability[3] * factor
// againThenGoodStep = stability[4] * factor
const learningStep2 = calculateStep(Math.min(stability[2] * 2 - stability[1], stability[3], stability[4]), factor);

learningStepRow.innerText = `${{learningStep1}} ${{learningStep2}}`;
learningStepRow.innerText = (!learningStep1 && !learningStep2)
? "You don't need learning steps"
: `${{learningStep1}} ${{learningStep2}}`;

relearningStepRow.innerText = calculateStep(stability[0], factor);
const relearningStep = calculateStep(stability[0], factor);
relearningStepRow.innerText = !relearningStep
? "You don't need relearning steps"
: relearningStep;
}};

calculateSteps();

document.querySelector('#desired-retention').addEventListener('input', calculateSteps);
</script>
"""
if not not_enough_data
else ""
)

html += "</table>"
html += (
Expand Down
Loading