Added a way to get the latest revlog entry for a card.
This commit is contained in:
parent
7f3ffc00f6
commit
5526956698
@ -753,8 +753,17 @@ class CardHandler(RestHandlerBase):
|
|||||||
if opts.get('load_deck', False):
|
if opts.get('load_deck', False):
|
||||||
d['deck'] = card.col.decks.get(card.did)
|
d['deck'] = card.col.decks.get(card.did)
|
||||||
|
|
||||||
|
if opts.get('load_latest_revlog', False):
|
||||||
|
d['latest_revlog'] = CardHandler._latest_revlog(card.col, card.id)
|
||||||
|
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _latest_revlog(col, card_id):
|
||||||
|
r = col.db.first("SELECT r.id, r.ease FROM revlog AS r WHERE r.cid = ? ORDER BY id DESC LIMIT 1", card_id)
|
||||||
|
if r:
|
||||||
|
return {'id': r[0], 'ease': r[1], 'timestamp': int(r[0] / 1000)}
|
||||||
|
|
||||||
def index(self, col, req):
|
def index(self, col, req):
|
||||||
card = col.getCard(req.ids[1])
|
card = col.getCard(req.ids[1])
|
||||||
return self._serialize(card, req.data)
|
return self._serialize(card, req.data)
|
||||||
@ -779,6 +788,9 @@ class CardHandler(RestHandlerBase):
|
|||||||
card = col.getCard(req.ids[1])
|
card = col.getCard(req.ids[1])
|
||||||
return col.cardStats(card)
|
return col.cardStats(card)
|
||||||
|
|
||||||
|
def latest_revlog(self, col, req):
|
||||||
|
return self._latest_revlog(col, req.ids[1])
|
||||||
|
|
||||||
# Our entry point
|
# Our entry point
|
||||||
def make_app(global_conf, **local_conf):
|
def make_app(global_conf, **local_conf):
|
||||||
# TODO: we should setup the default language from conf!
|
# TODO: we should setup the default language from conf!
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user