mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 14:32:22 -04:00
reimplement history sync in raw sql
This commit is contained in:
parent
c0e5bed6a6
commit
bb2c38e723
1 changed files with 27 additions and 11 deletions
38
anki/sync.py
38
anki/sync.py
|
@ -591,19 +591,35 @@ values
|
||||||
stat.toDB(self.deck.s)
|
stat.toDB(self.deck.s)
|
||||||
|
|
||||||
def bundleHistory(self):
|
def bundleHistory(self):
|
||||||
def bundleHist(hist):
|
return self.realTuples(self.deck.s.all("""
|
||||||
h = self.dictFromObj(hist)
|
select cardId, time, lastInterval, nextInterval, ease, delay,
|
||||||
del h['id']
|
lastFactor, nextFactor, reps, thinkingTime, yesCount, noCount
|
||||||
return h
|
from reviewHistory where time > :ls""",
|
||||||
hst = self.deck.s.query(CardHistoryEntry).filter(
|
ls=self.deck.lastSync))
|
||||||
CardHistoryEntry.time > self.deck.lastSync)
|
|
||||||
return [bundleHist(h) for h in hst]
|
|
||||||
|
|
||||||
def updateHistory(self, history):
|
def updateHistory(self, history):
|
||||||
for h in history:
|
dlist = [{'cardId': h[0],
|
||||||
ent = CardHistoryEntry()
|
'time': h[1],
|
||||||
self.applyDict(ent, h)
|
'lastInterval': h[2],
|
||||||
self.deck.s.save(ent)
|
'nextInterval': h[3],
|
||||||
|
'ease': h[4],
|
||||||
|
'delay': h[5],
|
||||||
|
'lastFactor': h[6],
|
||||||
|
'nextFactor': h[7],
|
||||||
|
'reps': h[8],
|
||||||
|
'thinkingTime': h[9],
|
||||||
|
'yesCount': h[10],
|
||||||
|
'noCount': h[11]} for h in history]
|
||||||
|
if not dlist:
|
||||||
|
return
|
||||||
|
self.deck.s.statements("""
|
||||||
|
insert into reviewHistory
|
||||||
|
(cardId, time, lastInterval, nextInterval, ease, delay,
|
||||||
|
lastFactor, nextFactor, reps, thinkingTime, yesCount, noCount)
|
||||||
|
values
|
||||||
|
(:cardId, :time, :lastInterval, :nextInterval, :ease, :delay,
|
||||||
|
:lastFactor, :nextFactor, :reps, :thinkingTime, :yesCount, :noCount)""",
|
||||||
|
dlist)
|
||||||
|
|
||||||
def bundleSources(self):
|
def bundleSources(self):
|
||||||
return self.realTuples(self.deck.s.all("select * from sources"))
|
return self.realTuples(self.deck.s.all("select * from sources"))
|
||||||
|
|
Loading…
Reference in a new issue