Skip to content

Optimize canAddNotes#44

Merged
KamWithK merged 11 commits intoKamWithK:masterfrom
Aquafina-water-bottle:optimize_queries
Oct 6, 2023
Merged

Optimize canAddNotes#44
KamWithK merged 11 commits intoKamWithK:masterfrom
Aquafina-water-bottle:optimize_queries

Conversation

@Aquafina-water-bottle
Copy link
Copy Markdown
Contributor

@Aquafina-water-bottle Aquafina-water-bottle commented Jun 17, 2023

If all of the model names are the same in canAddNotes (which is always true for Yomichan, because Yomichan only attempts to add one note type), then we can optimize the call using AnkiDroid's findDuplicateNotes call. This speeds up duplicate checks quite a bit from personal testing.

If the model names are not all the same, then we fallback to the original code.

The README still recommends to have the max results as 8 because the default 32 results is still a bit slow compared to the PC version. (Note: "max results" means the maximum number of results from Yomichan's popup, i.e. under General -> Maximum number of results)

The optimized query may partially fix quotes and spaces not working in the key field, because AnkiDroid's internal implementation uses a checksum instead of comparing the raw field. This does not fix Yomichan's findNotes call though, so the book (to open the most recent card) may not show.

Depends on #42

@KamWithK KamWithK merged commit 2a054fc into KamWithK:master Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants