AnKing-VIP / advanced-browser

Anki add-on with card browser enhancements.
GNU General Public License v3.0
56 stars 13 forks source link

also show overdue values when in filtered deck #150

Closed ijgnd closed 1 year ago

ijgnd commented 1 year ago

caveat: this doesn't allow sorting by the overdue value when you are in a filtered deck. But it should be an improvement.

ijgnd commented 1 year ago

the relevant issue is #146

ijgnd commented 1 year ago

@abdnh: If you have some time could you have a look at this? Maybe it's a quick fix for you to also allow to sort cards in filtered decks by overdue value because of your work on #144 yesterday? That would be great. Thanks.

Else I suggest to leave this pull request open.

abdnh commented 1 year ago

Will look into it

ijgnd commented 1 year ago

I'm pretty sure that before Anki moved to the sql code from python to rust around 2.1.24 you could sort by this column. I rememberd that I had an unpublished fork for ~2.1.15.2.1.22 where I had overdue values shown for cards in filtered decks (see code at https://github.com/ijgnd/advanced-browser/commit/ffce66ebb89184fcd6b3d7f33b309cd03d6cf646) that extended code for a new column "percent of scheduled ivl"; the code is at https://github.com/ijgnd/advanced-browser/commit/f734c83af7f6302de83976a85a4cb70e808be564

abdnh commented 1 year ago

This should do it

diff --git a/advancedbrowser/advancedbrowser/advanced_fields.py b/advancedbrowser/advancedbrowser/advanced_fields.py
index 5e58fe3..408334a 100644
--- a/advancedbrowser/advancedbrowser/advanced_fields.py
+++ b/advancedbrowser/advancedbrowser/advanced_fields.py
@@ -149,11 +149,11 @@ class AdvancedFields:
         srt = (f"""
         (select
           (case
-             when odid then null
              when queue = {QUEUE_TYPE_LRN} then null
              when queue = {QUEUE_TYPE_NEW} then null
              when type = {CARD_TYPE_NEW} then null
              when {mw.col.sched.today} - due <= 0 then null
+             when odid then ({mw.col.sched.today} - odue)
              when (queue = {QUEUE_TYPE_REV} or queue = {QUEUE_TYPE_DAY_LEARN_RELEARN} or (type = {CARD_TYPE_REV} and queue < 0)) then ({mw.col.sched.today} - due)
            end
           )
ijgnd commented 1 year ago

I made a new branch "fix-overdue" with two commits:

Then I merged the branch "fix-overdue" into

3_5_1_maintenance_for_Anki_24-34
3_7_maintenance_for_Anki_versions_35-40
3_9_maintenance_for_41-44
master