-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow setting sort_field from model #42
Conversation
I'm using a custom fork of this package to ease notes sorting inside Anki. A pull-request [1] with the modifications to genanki has been submitted: in the future, I may update the submodule dependancy to the original genanki repo [2]. [1] kerrickstaley/genanki#42 [2] https://github.com/kerrickstaley/genanki
I'm using a custom fork of this package to ease notes sorting inside Anki. A pull-request [1] with the modifications to genanki has been submitted: in the future, I may update the submodule dependancy to the original genanki repo [2]. [1] kerrickstaley/genanki#42 [2] https://github.com/kerrickstaley/genanki
6b0b68d
to
788fbbe
Compare
It is now possible to define a `sort_field` value for notes by setting a `sort_field_number` when creating the model. When the `sort_field` argument is unused upon note creation, then the field corresponding to the models `sort_field_number` will be used. The default value is `1` (for first field). The changes are compatible with previous versions.
Sorry I don't know why it says I closed the PR... I forced-push on my master branch after rebasing on top of your master branch and resolving conflicts. I am normally two commits ahead. |
This prevents potentially breaking the API, because the order of the arguments is part of the API.
@remiberthoz I pushed one quick change to your PR to avoid potentially breaking API compatibility, and it looks good to merge 😄 Will merge it momentarily once the CI tests pass. One note is that we need to add tests that exercise this functionality. I can do that in the next few days or if you want to take it on, just comment here to let me know so we don't duplicate work. |
Hey, I will write the tests! What behaviors would you like to test against? Of course, that the sorting index actually sorts when its used. Do you have edge-cases in mind? |
@remiberthoz I think a simple "happy path" test case would be fine for this feature, just to make sure nobody accidentally breaks it in the future. |
Hi! Here is the test discussed in #42 - I hope it's fine 😄
It is now possible to define a
sort_field
value for notes bysetting a
sort_field_number
when creating the model.When the
sort_field
argument is unused upon note creation, thenthe field corresponding to the models
sort_field_number
will beused. The default value is
1
(for first field).The changes are compatible with previous versions.