Merge pull request #15 from techdavid/fast-browse

Add fast non-GUI browse function
This commit is contained in:
Alex Yatskov 2017-07-21 12:47:23 -07:00 committed by GitHub
commit fbf938bf49
2 changed files with 35 additions and 0 deletions

View File

@ -456,6 +456,13 @@ class AnkiBridge:
return browser.model.cards return browser.model.cards
def browse(self, query=None):
if query is not None:
return aqt.mw.col.findCards(query)
else:
return []
def guiAddCards(self): def guiAddCards(self):
addCards = aqt.dialogs.open('AddCards', self.window()) addCards = aqt.dialogs.open('AddCards', self.window())
addCards.activateWindow() addCards.activateWindow()
@ -676,6 +683,11 @@ class AnkiConnect:
return self.anki.guiBrowse(query) return self.anki.guiBrowse(query)
@webApi
def browse(self, query=None):
return self.anki.browse(query)
@webApi @webApi
def guiAddCards(self): def guiAddCards(self):
return self.anki.guiAddCards() return self.anki.guiAddCards()

View File

@ -300,6 +300,29 @@ Below is a list of currently supported actions. Requests with invalid actions or
] ]
``` ```
* **browse**
Functionally identical to **guiBrowse**, but accesses the database without using the GUI for increased performance.
*Sample request*:
```
{
"action": "browse",
"params": {
"query": "deck:current"
}
}
```
*Sample response*:
```
[
1494723142483,
1494703460437,
1494703479525
]
```
* **guiAddCards** * **guiAddCards**
Invokes the AddCards dialog. Invokes the AddCards dialog.