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:
Alex Yatskov 2020-04-19 11:06:27 -07:00 committed by GitHub
commit 496db484c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 ####
* **deckNames**

View File

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

View File

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