add api to get number of cards reviewed in the current day
partly addresses issue raised in #117
This commit is contained in:
parent
b02f9d6c47
commit
f280a2b8f9
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 ####
|
||||
|
||||
* **deckNames**
|
||||
|
@ -285,6 +285,11 @@ class AnkiConnect:
|
||||
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
|
||||
#
|
||||
|
@ -20,6 +20,10 @@ class TestMisc(unittest.TestCase):
|
||||
self.assertIsNone(result['error'])
|
||||
self.assertEqual(result['result'], 6)
|
||||
|
||||
# getNumCardsReviewedToday
|
||||
result = util.invoke('getNumCardsReviewedToday')
|
||||
self.assertIsInstance(result, int)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
Loading…
Reference in New Issue
Block a user