From cb34becc17235db6f3c5dabe0b2fc3f564100777 Mon Sep 17 00:00:00 2001 From: Jarrett Ye Date: Mon, 11 Nov 2024 15:02:38 +0800 Subject: [PATCH] Feat/format time & remove delay limit (#490) --- stats.py | 8 ++++---- steps.py | 6 ++---- utils.py | 11 +++++++++++ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/stats.py b/stats.py index 9d4e98b..6d3d922 100644 --- a/stats.py +++ b/stats.py @@ -174,14 +174,14 @@ def get_steps_stats(self: CollectionStats): {style.title()} {stats['r1']} - {stats['delay_q1'] / 60:.2f} min + {format_time(stats['delay_q1'])} {stats['r2']} - {stats['delay_q2'] / 60:.2f} min + {format_time(stats['delay_q2'])} {stats['r3']} - {stats['delay_q3'] / 60:.2f} min + {format_time(stats['delay_q3'])} {stats['r4']} {stats['retention']} - {results['stability'][rating] / 60:.2f} min + {format_time(results['stability'][rating])} {stats['count']} """ diff --git a/steps.py b/steps.py index 17c6a3d..b3beb7b 100644 --- a/steps.py +++ b/steps.py @@ -11,7 +11,7 @@ def total_loss(points, stability): return sum(log_loss(y, power_forgetting_curve(x, stability)) for x, y in points) -def binary_search(points, low=1, high=86400, tolerance=1e-6): +def binary_search(points, low=1, high=86400 * 30, tolerance=1e-6): while high - low > tolerance: mid = (low + high) / 2 left = mid - tolerance @@ -43,8 +43,7 @@ def steps_stats(lim): ROW_NUMBER() OVER (PARTITION BY r.cid ORDER BY r.id) AS review_order FROM revlog r JOIN first_review fr ON r.cid = fr.cid AND r.id > fr.first_id - WHERE (r.id - fr.first_id) <= 43200000 - AND r.ease BETWEEN 1 AND 4 + WHERE r.ease BETWEEN 1 AND 4 ), review_stats AS ( SELECT fr.first_rating, @@ -86,7 +85,6 @@ def steps_stats(lim): (nr.next_id - nr.first_id) / 1000.0 AS delta_t, nr.recall FROM next_review nr - WHERE (nr.next_id - nr.first_id) <= 43200000 ) SELECT delta_t, diff --git a/utils.py b/utils.py index b711934..6b6cccf 100644 --- a/utils.py +++ b/utils.py @@ -244,3 +244,14 @@ def ask_one_way_sync(): + "and not synced them to this device yet, please do so before you proceed.\n" + "Do you want to proceed?" ) + + +def format_time(x, pos=None): + if x < 60: + return f"{x:.0f}s" + elif x < 3600: + return f"{x/60:.2f}m" + elif x < 86400: + return f"{x/3600:.2f}h" + else: + return f"{x/86400:.2f}d"