Arthur-Milchior / anki-copy-note

An add-on to copy anki's note
GNU General Public License v3.0
23 stars 9 forks source link

Review History is not Copied Correctly #39

Open ohare93 opened 3 years ago

ohare93 commented 3 years ago

Title.

I copy a note which has 6 mature cards. In the copied version only one card has any review history, and all of said history is erroneously on that one Card. So that card has review history, but it does not sync up with the original card.

Anki version: 2.1.44

ohare93 commented 3 years ago

Furthermore, the Copy Log config setting seems to do nothing. I disabled it, and yet it still erroneously copies the review history. Even a restart of Anki did not help.

ijgnd commented 3 years ago

possibly related: #21

the Copy Log config setting seems to do nothing

My understanding is that the old copy log functionality (on ankiweb for versions <45) is broken, see https://github.com/Arthur-Milchior/anki-copy-note/blob/c87e2d6eef9546873def5114ae8e9aecbdb69b5b/copyNote.py#L116

the code is

oid = card.id
# ....
for data in mw.col.db.all("select * from revlog where id = ?", oid):
    copyLog(data, card.id)

when you check the database structure the id field in the revlog table refers to the time of a repetition,
https://github.com/ankidroid/Anki-Android/wiki/Database-Structure .

So I think the old version of the add-on can't copy any log info for any card.

I'd change the database lookup from where id to where cid:

for data in mw.col.db.all("select * from revlog where cid = ?", oid):

I think that's a typo in the code.

I proposed changing this for .45+ to Arthur and he merged my change (though he relied on me getting this right ...). Let me know if you think that my solution is wrong.

If my understanding is right none of your new cards should have any history (unless the very unlikely case happens that a new card id happens to match a prior review time by the millisecond). So it worries me that in your first post you write that one card had a review log. So maybe I'm getting something totally wrong here ....