add api to get number of cards reviewed in the current day

partly addresses issue raised in #117
This commit is contained in:
yakrider 2020-04-18 21:16:52 -04:00
parent b02f9d6c47
commit f280a2b8f9
3 changed files with 29 additions and 0 deletions

View File

@ -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**

View File

@ -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
# #

View File

@ -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()