diff --git a/README.md b/README.md index 06a8bbb..05af260 100644 --- a/README.md +++ b/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** diff --git a/plugin/__init__.py b/plugin/__init__.py index f5a96d7..7113bfc 100644 --- a/plugin/__init__.py +++ b/plugin/__init__.py @@ -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 # diff --git a/tests/test_misc.py b/tests/test_misc.py index 3115e34..75949cf 100755 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -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()