ankidroid / Anki-Android

AnkiDroid: Anki flashcards on Android. Your secret trick to achieve superhuman information retention.
GNU General Public License v3.0
8.39k stars 2.18k forks source link

[BUG]: Duplicate checks only detect recently exported cards, AnkiDroid API #13561

Closed arianneorpilla closed 1 year ago

arianneorpilla commented 1 year ago

Checked for duplicates?

What are the steps to reproduce this bug?

I'm the developer of a language learning app for Japanese called jidoujisho and recently I implemented duplicate checks for my app.

Users can create cards with my app, and I use the first field of a dictionary word for cards exported to check for duplicates.

To reproduce, you can look at my code for how I implement this in my project.

I understand that this is not a core AnkiDroid issue, but I am an API consumer so I hope this is the correct place to get support for this.

The function I rely on from the API: https://github.com/ankidroid/Anki-Android/blob/504c23b4aae782ac2b3335d28e853706b0b0846b/api/src/main/java/com/ichi2/anki/api/AddContentApi.kt#L190

Native Android function call for duplicate check: https://github.com/lrorpilla/jidoujisho/blob/afd2b2ba8f3da5fb33bb5af2f5dd53c4b1dd9000/yuuna/android/app/src/main/java/app/lrorpilla/yuuna/MainActivity.java#L157

How I call the Android method channel in my Flutter app: https://github.com/lrorpilla/jidoujisho/blob/afd2b2ba8f3da5fb33bb5af2f5dd53c4b1dd9000/yuuna/lib/src/models/app_model.dart#L1784

I know it might be unreasonable to ask a developer to install my application so they can see the behaviour but that would also be a fast and sure way to reproduce, latest release is as linked https://github.com/lrorpilla/jidoujisho/releases/tag/2.6.2

I will probably edit with more details as I go if required

Expected behaviour

I expect that duplicate checks return all notes for a given model ID and first field key.

Suppose Card A is a card with the first field value A

I make Card A App installed Check for duplicates Card A is detected Export a Card A with my app Card A is detected

Actual behaviour

For some reason, duplicate checks only work for recently exported cards from after my app is installed. Cards made before my app checked for duplicates are NOT included and returned in the duplicate check.

Suppose Card A is a card with the first field value A

I make Card A App installed Check for duplicates Card A is not detected Export a Card A with my app Card A is detected

Debug info

AnkiDroid Version = 2.15.6

Android Version = 13

Manufacturer = Google

Model = Pixel 6 Pro

Hardware = raven

Webview User Agent = Mozilla/5.0 (Linux; Android 13; Pixel 6 Pro Build/TQ2A.230305.008.E1; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/111.0.5563.116 Mobile Safari/537.36

ACRA UUID = f8260709-3407-46a0-9e17-3238ee022ea8

Scheduler = std

Crash Reports Enabled = true

DatabaseV2 Enabled = true

(Optional) Anything else you want to share?

Again, I understand this is not an issue affecting AnkiDroid users but I hope I can get help getting this resolved -- I am willing to debug on my end and give more information if requested as I know the developers here aren't involved with my project,

I would really like to know why this behaviour is happening

Research

arianneorpilla commented 1 year ago

Hi @mikehardy and @david-allison, sorry for the ping but I was wondering if you could take a look at this issue?

I'm not sure if I'm doing something wrong in my own end implementing this or if it's an AnkiDroid API issue. Thought I would follow up as my own users are pressing me about this.

arianneorpilla commented 1 year ago

I tried using the Rust backend and upgraded to the latest alpha and I have the same issue.

arianneorpilla commented 1 year ago

It seems that exporting the cards in, deleting, then importing them back in has made it work, but this was a strange thing to have to do, and I still want to learn what's going on if possible.

github-actions[bot] commented 1 year ago

Hello 👋, this issue has been opened for more than 3 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like still searching for solutions and if you found one, please open a pull request! You have 7 days until this gets closed automatically