Make note/card endpoints more like existing endpoints, removing some Anki-internal fields from it

card.type, card.queue and card.due seem difficult to use to me, maybe
card due date should be introduced when it's represented in a more
meaningful way (like an actual date instead of an integer day).
This commit is contained in:
ReneBrals 2018-01-09 14:09:38 +01:00
parent 63c2eb4887
commit cd6dd8479c

View File

@ -718,7 +718,7 @@ class AnkiBridge:
for info in model['flds']: for info in model['flds']:
order = info['ord'] order = info['ord']
name = info['name'] name = info['name']
fields[name] = note.fields[order] fields[name] = {'value': note.fields[order], 'order': order}
result.append({ result.append({
'cardId': card.id, 'cardId': card.id,
@ -733,16 +733,6 @@ class AnkiBridge:
#This factor is 10 times the ease percentage, #This factor is 10 times the ease percentage,
# so an ease of 310% would be reported as 3100 # so an ease of 310% would be reported as 3100
'interval': card.ivl, 'interval': card.ivl,
'type': card.type,
#new = 0, learning = 1, review = 2
'queue': card.queue,
# same as type, plus:
# suspended = -1, user buried = -2, sched buried = -3
'due': card.due,
# does different things depending on queue,
# new: position in queue
# learning: integer timestamp
# review: integer days (since first review)
'note': card.nid 'note': card.nid
}) })
except TypeError as e: except TypeError as e:
@ -765,13 +755,14 @@ class AnkiBridge:
for info in model['flds']: for info in model['flds']:
order = info['ord'] order = info['ord']
name = info['name'] name = info['name']
fields[name] = note.fields[order] fields[name] = {'value': note.fields[order], 'order': order}
result.append({ result.append({
'noteId': note.id, 'noteId': note.id,
'tags' : note.tags, 'tags' : note.tags,
'fields': fields, 'fields': fields,
'modelName': model['name'], 'modelName': model['name'],
'cards': note.cards()
}) })
except TypeError as e: except TypeError as e:
# Anki will give a TypeError if the note ID does not exist. # Anki will give a TypeError if the note ID does not exist.