open-spaced-repetition / fsrs4anki-helper

An Anki add-on that supports Postpone & Advance & Load Balance & Easy Days & Disperse Siblings & Flatten
https://ankiweb.net/shared/info/759844606
MIT License
213 stars 17 forks source link

[BUG] error when using flatten feature #449

Closed jajolt11 closed 2 months ago

jajolt11 commented 2 months ago

error when using flatten feature

To Reproduce Steps to reproduce the behavior:

  1. Go to deck settings
  2. Click on 'Flatten future due cards'
  3. See error

Expected behavior future dues will be flattened Debug info: Anki 23.12.1 (1a1d4d54) (ao) Python 3.9.15 Qt 6.5.3 PyQt 6.5.3 Platform: macOS-14.6.1-arm64-arm-64bit

Traceback (most recent call last): File "aqt.taskman", line 142, in _on_closures_pending File "aqt.taskman", line 86, in File "/Users/computer/Library/Application Support/Anki2/addons21/759844606/schedule/flatten.py", line 38, in on_done cnt, mean_prev_target_r, mean_new_target_r = future.result() File "concurrent.futures._base", line 439, in result File "concurrent.futures._base", line 391, in __get_result File "concurrent.futures.thread", line 58, in run File "/Users/computer/Library/Application Support/Anki2/addons21/759844606/schedule/flatten.py", line 47, in lambda: flatten_background(did, desired_flatten_limit), on_done File "/Users/computer/Library/Application Support/Anki2/addons21/759844606/schedule/flatten.py", line 188, in flatten_background mean_prev_target_r = sum(prev_target_rs) / len(prev_target_rs) ZeroDivisionError: division by zero

===Add-ons (active)=== (add-on provided name [Add-on folder, installed at, version, is config changed]) AMBOSS add-on ['0amboss_addon', 2024-08-05T09:24, 'None', mod] AnKing Note Types Easy Customization ['952691989', 2024-08-19T03:41, 'None', mod] Anki Simulator ['817108664', 2023-11-06T11:26, 'None', ''] AnkiHub ['1322529746', 2024-07-09T12:26, 'None', mod] Batch Editing ['291119185', 2023-10-25T19:38, 'None', ''] Calculate New Cards To Do ['2014569756', 2022-05-19T00:38, 'None', ''] Closet For Anki ['272311064', 2022-08-12T03:27, 'None', ''] FSRS Helper Postpone Advance Load Balance Easy Days Disperse Siblings ['759844606', 2024-08-18T21:05, 'None', mod] Find cards from UWorld test ['444814983', 2024-07-19T01:19, 'None', ''] Image Occlusion Enhanced ['1374772155', 2022-04-09T02:15, 'None', ''] Review Heatmap ['1771074083', 2022-06-29T20:43, 'None', ''] Scale Images ['1312865748', 2023-11-02T01:45, 'None', ''] The KING of Study Timers ['907028815', 2022-04-20T13:14, 'None', ''] Weekends and Holidays ['1992008104', 2022-12-19T19:24, 'None', mod]

===IDs of active AnkiWeb add-ons=== 1312865748 1322529746 1374772155 1771074083 1992008104 2014569756 272311064 291119185 444814983 759844606 817108664 907028815 952691989

===Add-ons (inactive)=== (add-on provided name [Add-on folder, installed at, version, is config changed]) Exam Notifier ['236593452', 2023-01-19T11:12, 'None', ''] Straight Reward ['957961234', 2023-11-01T09:11, 'None', ''] Symbols As You Type FIXED ['2088399109', 2023-12-14T12:45, 'None', '']

Environment in debug info

Additional context

L-M-Sherlock commented 2 months ago

I upload a patch here. Have a try: fsrs4anki-helper.ankiaddon.zip