getReviewsOfCards: changed inner lists into dictionaries, removed cid within the inner list
This commit is contained in:
parent
7cf38106b3
commit
a8905a4c22
41
README.md
41
README.md
@ -2767,8 +2767,21 @@ corresponding to when the API was available for use.
|
|||||||
* **getReviewsOfCards**
|
* **getReviewsOfCards**
|
||||||
|
|
||||||
Requests all card reviews for each card ID.
|
Requests all card reviews for each card ID.
|
||||||
Returns a dictionary mapping the card ID to 9-tuples in the same format as `cardReviews`:
|
Returns a dictionary mapping each card ID to a list of dictionaries of the format:
|
||||||
`(reviewTime, cardID, usn, buttonPressed, newInterval, previousInterval, newFactor, reviewDuration, reviewType)`
|
```
|
||||||
|
{
|
||||||
|
"id": reviewTime,
|
||||||
|
"usn": usn,
|
||||||
|
"ease": buttonPressed,
|
||||||
|
"ivl": newInterval,
|
||||||
|
"lastIvl": previousInterval,
|
||||||
|
"factor": newFactor,
|
||||||
|
"time": reviewDuration,
|
||||||
|
"type": reviewType,
|
||||||
|
}
|
||||||
|
```
|
||||||
|
The reason why these key values are used instead of the more descriptive counterparts
|
||||||
|
is because these are the exact key values used in Anki's database.
|
||||||
|
|
||||||
*Sample request*:
|
*Sample request*:
|
||||||
```json
|
```json
|
||||||
@ -2788,10 +2801,26 @@ corresponding to when the API was available for use.
|
|||||||
{
|
{
|
||||||
"result": {
|
"result": {
|
||||||
"1653613948202": [
|
"1653613948202": [
|
||||||
[1654102387663, 1653613948202, 1780, 3, 8, 3, 2500, 25796, 1],
|
{
|
||||||
[1654798974478, 1653613948202, 1861, 3, 20, 8, 2500, 18134, 1],
|
"id": 1653772912146,
|
||||||
[1656556319328, 1653613948202, 2075, 3, 53, 20, 2500, 20530, 1],
|
"usn": 1750,
|
||||||
[1661107990069, 1653613948202, 2478, 3, 131, 53, 2500, 24247, 1]
|
"ease": 1,
|
||||||
|
"ivl": -20,
|
||||||
|
"lastIvl": -20,
|
||||||
|
"factor": 0,
|
||||||
|
"time": 38192,
|
||||||
|
"type": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 1653772965429,
|
||||||
|
"usn": 1750,
|
||||||
|
"ease": 3,
|
||||||
|
"ivl": -45,
|
||||||
|
"lastIvl": -20,
|
||||||
|
"factor": 0,
|
||||||
|
"time": 15337,
|
||||||
|
"type": 0
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"error": null
|
"error": null
|
||||||
|
@ -1375,13 +1375,15 @@ class AnkiConnect:
|
|||||||
|
|
||||||
@util.api()
|
@util.api()
|
||||||
def getReviewsOfCards(self, cards):
|
def getReviewsOfCards(self, cards):
|
||||||
return {
|
COLUMNS = ['id', 'usn', 'ease', 'ivl', 'lastIvl', 'factor', 'time', 'type']
|
||||||
card: self.database().all(
|
QUERY = 'select {} from revlog where cid = ?'.format(', '.join(COLUMNS))
|
||||||
"select id, cid, usn, ease, ivl, lastIvl, factor, time, type from revlog where cid = ?",
|
|
||||||
card,
|
result = {}
|
||||||
)
|
for card in cards:
|
||||||
for card in cards
|
query_result = self.database().all(QUERY, card)
|
||||||
}
|
result[card] = [dict(zip(COLUMNS, row)) for row in query_result]
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,4 +30,17 @@ class TestReviews:
|
|||||||
assert len(ac.cardReviews(deck="test_deck", startID=0)) == 2
|
assert len(ac.cardReviews(deck="test_deck", startID=0)) == 2
|
||||||
assert ac.getLatestReviewID(deck="test_deck") == 789
|
assert ac.getLatestReviewID(deck="test_deck") == 789
|
||||||
assert ac.getReviewsOfCards(cards=[setup.card_ids[0]]) == \
|
assert ac.getReviewsOfCards(cards=[setup.card_ids[0]]) == \
|
||||||
{setup.card_ids[0]: [[456, setup.card_ids[0], -1, 3, 4, -60, 2500, 6157, 0]]}
|
{
|
||||||
|
setup.card_ids[0]: [
|
||||||
|
{
|
||||||
|
"id": 456,
|
||||||
|
"usn": -1,
|
||||||
|
"ease": 3,
|
||||||
|
"ivl": 4,
|
||||||
|
"lastIvl": -60,
|
||||||
|
"factor": 2500,
|
||||||
|
"time": 6157,
|
||||||
|
"type": 0,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user