This commit is contained in:
commit
c8501cf8aa
@ -228,6 +228,10 @@ class RestApp(object):
|
||||
logging.error(req.path+': Unable to parse JSON: '+str(e), exc_info=True)
|
||||
raise HTTPBadRequest()
|
||||
|
||||
# fix for a JSON encoding 'quirk' in PHP
|
||||
if type(data) == list and len(data) == 0:
|
||||
data = {}
|
||||
|
||||
# make the keys into non-unicode strings
|
||||
data = dict([(str(k), v) for k, v in data.items()])
|
||||
|
||||
@ -545,6 +549,32 @@ class CollectionHandler(RestHandlerBase):
|
||||
|
||||
return result
|
||||
|
||||
def latest_revlog(self, col, req):
|
||||
"""Returns recent entries from the revlog."""
|
||||
|
||||
# TODO: Use sqlalchemy to build this query!
|
||||
sql = "SELECT r.id, r.ease, r.cid, r.usn, r.ivl, r.lastIvl, r.factor, r.time, r.type FROM revlog AS r"
|
||||
args = []
|
||||
if req.data.has_key('updated_since'):
|
||||
sql += ' WHERE r.id > ?'
|
||||
args.append(long(req.data['updated_since']) * 1000)
|
||||
sql += ' ORDER BY r.id DESC'
|
||||
sql += ' LIMIT ' + str(req.data.get('limit', 100))
|
||||
|
||||
revlog = col.db.all(sql, *args)
|
||||
return [{
|
||||
'id': r[0],
|
||||
'ease': r[1],
|
||||
'timestamp': int(r[0] / 1000),
|
||||
'card_id': r[2],
|
||||
'usn': r[3],
|
||||
'interval': r[4],
|
||||
'last_interval': r[5],
|
||||
'factor': r[6],
|
||||
'time': r[7],
|
||||
'type': r[8],
|
||||
} for r in revlog]
|
||||
|
||||
stats_reports = {
|
||||
'today': 'todayStats',
|
||||
'due': 'dueGraph',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user