@@ 409,6 409,16 @@ class AnkiBridge:
return False
+ def getIntervals(self, cards, complete=False):
+ intervals = []
+ for card in cards:
+ interval = self.window().col.db.list('select ivl from revlog where cid = ?', card)
+ if not complete:
+ interval = interval[-1]
+ intervals.append(interval)
+ return intervals
+
+
def startEditing(self):
self.window().requireReset()
@@ 497,6 507,10 @@ class AnkiBridge:
return []
+ def cardsToNotes(self, cards):
+ return self.window().col.db.list('select distinct nid from cards where id in ' + anki.utils.ids2str(cards))
+
+
def guiBrowse(self, query=None):
browser = aqt.dialogs.open('Browser', self.window())
browser.activateWindow()
@@ 729,6 743,11 @@ class AnkiConnect:
@webApi
+ def getIntervals(self, cards, complete=False):
+ return self.anki.getIntervals(cards, complete)
+
+
+ @webApi
def upgrade(self):
response = QMessageBox.question(
self.anki.window(),
@@ 767,6 786,11 @@ class AnkiConnect:
@webApi
+ def cardsToNotes(self, cards):
+ return self.anki.cardsToNotes(cards)
+
+
+ @webApi
def guiBrowse(self, query=None):
return self.anki.guiBrowse(query)
@@ 404,6 404,46 @@ Below is a list of currently supported actions. Requests with invalid actions or
false
```
+* **getIntervals**
+
+ Returns an array of the most recent intervals for each given card ID, or a 2-dimensional array of all the intervals
+ for each given card ID when `complete` is `true`. (Negative intervals are in seconds and positive intervals in days.)
+
+ *Sample request 1*:
+ ```
+ {
+ "action": "getIntervals",
+ "params": {
+ "cards": [1502298033753, 1502298036657]
+ }
+ }
+ ```
+
+ *Sample response 1*:
+ ```
+ [-14400, 3]
+ ```
+
+ *Sample request 2*:
+ ```
+ {
+ "action": "getIntervals",
+ "params": {
+ "cards": [1502298033753, 1502298036657],
+ "complete": true
+ }
+ }
+ ```
+
+ *Sample response 2*:
+ ```
+ [
+ [-120, -180, -240, -300, -360, -14400],
+ [-120, -180, -240, -300, -360, -14400, 1, 3]
+ ]
+ ```
+
+
* **findNotes**
Returns an array of note IDs for a given query (same query syntax as **guiBrowse**).
@@ 411,7 451,7 @@ Below is a list of currently supported actions. Requests with invalid actions or
*Sample request*:
```
{
- "action": "findCards",
+ "action": "findNotes",
"params": {
"query": "deck:current"
}
@@ 450,6 490,29 @@ Below is a list of currently supported actions. Requests with invalid actions or
]
```
+* **cardsToNotes**
+
+ Returns an (unordered) array of note IDs for the given card IDs. For cards with the same note, the ID is only
+ given once in the array.
+
+ *Sample request*:
+ ```
+ {
+ "action": "cardsToNotes",
+ "params": {
+ "cards": [1502098034045, 1502098034048, 1502298033753]
+ }
+ }
+ ```
+
+ *Sample response*:
+ ```
+ [
+ 1502098029797,
+ 1502298025183
+ ]
+ ```
+
* **guiBrowse**
Invokes the card browser and searches for a given query. Returns an array of identifiers of the cards that were found.