Merge pull request #155 from yakrider/patch-1
add api to get number of cards reviewed in the current day
This commit is contained in:
commit
496db484c5
20
README.md
20
README.md
@ -277,6 +277,26 @@ guarantee that your application continues to function properly in the future.
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
* **getNumCardsReviewedToday**
|
||||||
|
|
||||||
|
Gets the count of cards that have been reviewed in the current day (with day start time as configured by user in anki)
|
||||||
|
|
||||||
|
*Sample request*:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"action": "getNumCardsReviewedToday",
|
||||||
|
"version": 6
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
*Sample result*:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"result": 0,
|
||||||
|
"error": null
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
#### Decks ####
|
#### Decks ####
|
||||||
|
|
||||||
* **deckNames**
|
* **deckNames**
|
||||||
|
@ -285,6 +285,11 @@ class AnkiConnect:
|
|||||||
return list(map(self.handler, actions))
|
return list(map(self.handler, actions))
|
||||||
|
|
||||||
|
|
||||||
|
@util.api()
|
||||||
|
def getNumCardsReviewedToday(self):
|
||||||
|
return self.database().scalar('select count() from revlog where id > ?', (self.scheduler().dayCutoff - 86400) * 1000)
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Decks
|
# Decks
|
||||||
#
|
#
|
||||||
|
@ -20,6 +20,10 @@ class TestMisc(unittest.TestCase):
|
|||||||
self.assertIsNone(result['error'])
|
self.assertIsNone(result['error'])
|
||||||
self.assertEqual(result['result'], 6)
|
self.assertEqual(result['result'], 6)
|
||||||
|
|
||||||
|
# getNumCardsReviewedToday
|
||||||
|
result = util.invoke('getNumCardsReviewedToday')
|
||||||
|
self.assertIsInstance(result, int)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Loading…
Reference in New Issue
Block a user