mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
log updates & duplicates (#859)
This commit is contained in:
parent
a7b9a7b055
commit
3dd72ad4d6
2 changed files with 7 additions and 1 deletions
|
@ -109,6 +109,9 @@ class NoteImporter(Importer):
|
||||||
self._nextID = timestampID(self.col.db, "notes")
|
self._nextID = timestampID(self.col.db, "notes")
|
||||||
# loop through the notes
|
# loop through the notes
|
||||||
updates = []
|
updates = []
|
||||||
|
updateLog = []
|
||||||
|
updateLogTxt = _("Update as first field matched: %s")
|
||||||
|
dupeLogTxt = _("Added duplicate with first field: %s")
|
||||||
new = []
|
new = []
|
||||||
self._ids = []
|
self._ids = []
|
||||||
self._cards = []
|
self._cards = []
|
||||||
|
@ -146,10 +149,12 @@ class NoteImporter(Importer):
|
||||||
data = self.updateData(n, id, sflds)
|
data = self.updateData(n, id, sflds)
|
||||||
if data:
|
if data:
|
||||||
updates.append(data)
|
updates.append(data)
|
||||||
|
updateLog.append(updateLogTxt % fld0)
|
||||||
found = True
|
found = True
|
||||||
break
|
break
|
||||||
elif self.importMode == 2:
|
elif self.importMode == 2:
|
||||||
# allow duplicates in this case
|
# allow duplicates in this case
|
||||||
|
updateLog.append(dupeLogTxt % fld0)
|
||||||
found = False
|
found = False
|
||||||
# newly add
|
# newly add
|
||||||
if not found:
|
if not found:
|
||||||
|
@ -171,6 +176,7 @@ class NoteImporter(Importer):
|
||||||
part1 = ngettext("%d note added", "%d notes added", len(new)) % len(new)
|
part1 = ngettext("%d note added", "%d notes added", len(new)) % len(new)
|
||||||
part2 = ngettext("%d note updated", "%d notes updated", self.updateCount) % self.updateCount
|
part2 = ngettext("%d note updated", "%d notes updated", self.updateCount) % self.updateCount
|
||||||
self.log.append("%s, %s." % (part1, part2))
|
self.log.append("%s, %s." % (part1, part2))
|
||||||
|
self.log.extend(updateLog)
|
||||||
if self._emptyNotes:
|
if self._emptyNotes:
|
||||||
self.log.append(_("""\
|
self.log.append(_("""\
|
||||||
One or more notes were not imported, because they didn't generate any cards. \
|
One or more notes were not imported, because they didn't generate any cards. \
|
||||||
|
|
|
@ -213,7 +213,7 @@ def test_csv():
|
||||||
assert i.total == 5
|
assert i.total == 5
|
||||||
# if we run the import again, it should update instead
|
# if we run the import again, it should update instead
|
||||||
i.run()
|
i.run()
|
||||||
assert len(i.log) == 5
|
assert len(i.log) == 10
|
||||||
assert i.total == 5
|
assert i.total == 5
|
||||||
# but importing should not clobber tags if they're unmapped
|
# but importing should not clobber tags if they're unmapped
|
||||||
n = deck.getNote(deck.db.scalar("select id from notes"))
|
n = deck.getNote(deck.db.scalar("select id from notes"))
|
||||||
|
|
Loading…
Reference in a new issue