pass sole arg to cardStats as a dictionary

Easier to extend in the future, or (de)serialize in a strongly-typed
language.
This commit is contained in:
Damien Elmes 2021-10-14 19:10:06 +10:00
parent abad6c3844
commit e8c5802a96
2 changed files with 3 additions and 2 deletions

View file

@ -413,7 +413,8 @@ def complete_tag() -> bytes:
def card_stats() -> bytes:
return aqt.mw.col.card_stats_data(CardId(int(request.data)))
args = from_json_bytes(request.data)
return aqt.mw.col.card_stats_data(CardId(args["cardId"]))
# these require a collection

View file

@ -6,6 +6,6 @@ import { postRequest } from "../lib/postrequest";
export async function getCardStats(cardId: number): Promise<Stats.CardStatsResponse> {
return Stats.CardStatsResponse.decode(
await postRequest("/_anki/cardStats", JSON.stringify(cardId))
await postRequest("/_anki/cardStats", JSON.stringify({ cardId }))
);
}