[API] Added fields to cards endpoints#20589
Conversation
david-allison
left a comment
There was a problem hiding this comment.
Great start! Sorry, there's going to be a fair amount of nitpicking over the API, as breaking changes are hard work.
| @@ -608,6 +608,26 @@ public object FlashCardsContract { | |||
| */ | |||
| public const val DECK_ID: String = "deck_id" | |||
|
|
|||
| /** | |||
| * The total number of reviews this card has received. | |||
There was a problem hiding this comment.
This should be more detailed. What's a review? When does the count start? Does rescheduling cause this? Grade Now?
| public const val REPS: String = "reps" | ||
|
|
||
| /** | ||
| * The total number of times this card has lapsed. |
There was a problem hiding this comment.
This should be more detailed
| public const val LAPSES: String = "lapses" | ||
|
|
||
| /** | ||
| * The raw card type code. This is distinct from queue and note type. |
| public const val TYPE: String = "type" | ||
|
|
||
| /** | ||
| * The original deck id for cards currently in a filtered deck. This is 0 for regular cards. |
There was a problem hiding this comment.
reword 'regular cards' to be more precise
| } | ||
|
|
||
| @Test | ||
| fun testQueryCardRawPropertiesAcrossCardUris() { |
There was a problem hiding this comment.
One test per property. Compare to the value you set on the card, not the value on the Card object
|
Hi @lonewolf2208 try to use semantic commits |
|
Apologies @david-allison fixed the tests now |
This comment was marked as low quality.
This comment was marked as low quality.
|
@david-allison a friendly reminder to review this |
david-allison
left a comment
There was a problem hiding this comment.
Ahaa... API change, so docs should be 'perfect'
Code doesn't need changes.
| public const val LAPSES: String = "lapses" | ||
|
|
||
| /** | ||
| * The stored Anki card type code. This is distinct from queue and note type. |
There was a problem hiding this comment.
I don't think this helps describe the concept.
The type is the 'stage' in learning: treat it as a FSM. A card moves from 0 to 1, to 2, then from 2 to 3, to 2...
queue shares a lot of the same values, but it's about how to select the card: temporary actions such as bury or suspend can change the queue of a card to stop it from being displayed. The 'type' is more permanent: suspending and unsuspending a card would not impact whether to use learning steps or the card properties, and also does not affect FSRS.
There was a problem hiding this comment.
I added more comments - this is the onyl one I feel could do with another round
There was a problem hiding this comment.
Apologies @david-allison, for requesting another review on the same item. I’ve made the updates and hope it’s clearer this time - 55e9eea
| * Think of this as a simple state machine that affects how the card is scheduled when it | ||
| * is answered. A card typically moves `0 -> 1 -> 2`; if a review card lapses, it |
There was a problem hiding this comment.
A little informal, but I like it. LGTM!
|
Awesome seeing this already been done! This is my first time using the API and I was scratching my head trying to figure out how to access |
|
@NicolasNewman Thanks!! Feel free to list anything you create here: https://github.com/ankidroid/Anki-Android/wiki/Third-Party-Apps |
mikehardy
left a comment
There was a problem hiding this comment.
I'm all for API changes (well, well-considered ones) - the beauty of open code and open APIs is that you have no idea what people will build, but they can't if you don't open it up.
That's just a philosophical statement, you've put in the work here so I'm sure I'm preaching to the choir. Well done, and thanks, let's go
Refine card field docs and tests test: fix nullable cursor handling in provider tests docs: refine card field KDoc in FlashCardsContract docs: clarify FlashCardsContract.Card.TYPE KDoc
55e9eea to
e299c47
Compare
|
Pulled PR locally, rebased to current main, ran Going to squash locally (these seem like a single change...) then re-push with the commits nicely in the squash, then en-queue for our normal rebase-merge-queue 🫡 |
Purpose / Description
Fixes
CardContentProviderwith more fields fromCard#20458Approach
How Has This Been Tested?
Regarding below testing I tweaked the debug build to allow com.android.shell for manual provider queries; not part of the PR
verified that querying without an explicit projection still returned the old default fields, so the new fields remain opt-in
Learning (optional, can help others)
Have shared my learnings here in this comment
Checklist
Please, go through these checks before submitting the PR.