added getNumCardsReviewedByDay action (#239)
* added getNumCardsReviewedByDay action * added sample in statistics.md * fix bad quotes and add basic test
This commit is contained in:
parent
b8a7151ed0
commit
27a8678f88
@ -20,6 +20,29 @@
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
* **getNumCardsReviewedByDay**
|
||||||
|
|
||||||
|
Gets the number of cards reviewed as a list of pairs of `(dateString, number)`
|
||||||
|
|
||||||
|
*Sample request*:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"action": "getNumCardsReviewedByDay",
|
||||||
|
"version": 6,
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
*Sample result*:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"result": [
|
||||||
|
["2021-02-28", 124],
|
||||||
|
["2021-02-27", 261]
|
||||||
|
],
|
||||||
|
"error": null
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
* **getCollectionStatsHTML**
|
* **getCollectionStatsHTML**
|
||||||
|
|
||||||
Gets the collection statistics report
|
Gets the collection statistics report
|
||||||
|
@ -351,6 +351,11 @@ class AnkiConnect:
|
|||||||
def getNumCardsReviewedToday(self):
|
def getNumCardsReviewedToday(self):
|
||||||
return self.database().scalar('select count() from revlog where id > ?', (self.scheduler().dayCutoff - 86400) * 1000)
|
return self.database().scalar('select count() from revlog where id > ?', (self.scheduler().dayCutoff - 86400) * 1000)
|
||||||
|
|
||||||
|
@util.api()
|
||||||
|
def getNumCardsReviewedByDay(self):
|
||||||
|
return self.database().all('select date(id/1000 - ?, "unixepoch", "localtime") as day, count() from revlog group by day order by day desc',
|
||||||
|
int(time.strftime("%H", time.localtime(self.scheduler().dayCutoff))) * 3600)
|
||||||
|
|
||||||
|
|
||||||
@util.api()
|
@util.api()
|
||||||
def getCollectionStatsHTML(self, wholeCollection=True):
|
def getCollectionStatsHTML(self, wholeCollection=True):
|
||||||
|
@ -28,6 +28,10 @@ class TestStats(unittest.TestCase):
|
|||||||
result = util.invoke('getNumCardsReviewedToday')
|
result = util.invoke('getNumCardsReviewedToday')
|
||||||
self.assertIsInstance(result, int)
|
self.assertIsInstance(result, int)
|
||||||
|
|
||||||
|
# getNumCardsReviewedByDay
|
||||||
|
result = util.invoke('getNumCardsReviewedByDay')
|
||||||
|
self.assertIsInstance(result, list)
|
||||||
|
|
||||||
# collectionStats
|
# collectionStats
|
||||||
result = util.invoke('getCollectionStatsHTML')
|
result = util.invoke('getCollectionStatsHTML')
|
||||||
self.assertIsInstance(result, str)
|
self.assertIsInstance(result, str)
|
||||||
|
Loading…
Reference in New Issue
Block a user