glutanimate / pdf-glossary

PDF Glossary Export Add-on for Anki
GNU Affero General Public License v3.0
28 stars 2 forks source link

Exports not sorted by note creation date #2

Closed alex318 closed 6 years ago

alex318 commented 6 years ago

Is there a way to define the order of the cards on the pdf? I'd like to have them sorted by creation date.

Thank you!

andrewwlu commented 6 years ago

bumping this since it didn't get a reply - this would actually be super helpful to be able to sort by creation date. Thanks! The add-on is awesome

andrewwlu commented 6 years ago

@glutanimate

glutanimate commented 6 years ago

Thanks for writing. I'm glad you like the add-on. I agree that a customizable sorting order would be useful to have. Right now the add-on simply follows same order as all other exporters built into Anki. By default this is all cards sorted by their card ID. However, generally the card ID does align with the creation date. The only exceptions to this I can think of are:

Should none of the above apply in your cases, then I would appreciate if one of you guys could attach a sample deck here where you've been experiencing this issue. That way I can take a look myself and see what's going on.

andrewwlu commented 6 years ago

Hi @glutanimate, thanks for the response, I tested the export on 5 of my decks (each do not contain any subdecks) and the export order is never by creation date. There does seem to be some sort of pattern, as words created together tend to cluster together.

Here's an example: Default anki export file MCAT-Behavioral Sciences.zip

Creation order image

Addon export order MCAT-Behavioral Sciences.pdf

Thanks! Andrew

glutanimate commented 6 years ago

Thanks for the sample files!

So it looks like the DB query used by Anki's exporter class to identify all relevant cards doesn't specify any order by default. This can lead to a completely unpredictable order, which would explain why exports from some Anki collections would be sorted by creation date while others wouldn't. The solution will entail overriding the default card ID querying method with a custom one.

I don't have a lot of time on my hands right now, but if I find a free time slot I will try to work this in

andrewwlu commented 6 years ago

Got it, makes sense. Thanks for taking the time to look over this for us, much appreciated!! Andrew

andrewwlu commented 6 years ago

@glutanimate actually I was looking at this more closely and I'm still confused. I haven't looked closely at your code, but the default export option in Anki does export the cards in creation date order. At this point I'm just going to take their default exported .txt file and format it quickly to print, but for future reference that still seems a strange.

glutanimate commented 6 years ago

I have just pushed a commit to the repo that should address this. Please give it a try and let me know if it works for you (simply replacing pdf_glossary/exporter.py with the new version should apply the changes).

andrewwlu commented 6 years ago

@glutanimate worked beautifully!! Thanks so much for the help.

glutanimate commented 6 years ago

Sorry for the belated response. Glad to hear that the exports are working as expected now. I will be closing this issue for now and push a new build of the add-on to AnkiWeb soon-ish.