Log existing notes during CSV import (#2898)

This commit is contained in:
RumovZ 2023-12-22 05:01:35 +01:00 committed by GitHub
parent f2e9c73b31
commit 8537e85a64
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -335,16 +335,18 @@ impl<'a> Context<'a> {
fn import_note(&mut self, ctx: NoteContext, log: &mut NoteLog) -> Result<()> { fn import_note(&mut self, ctx: NoteContext, log: &mut NoteLog) -> Result<()> {
match self.dupe_resolution { match self.dupe_resolution {
_ if !ctx.is_dupe() => self.add_note(ctx, log)?, _ if ctx.dupes.is_empty() => self.add_note(ctx, log)?,
DupeResolution::Duplicate if ctx.is_guid_dupe() => { DupeResolution::Duplicate if ctx.is_guid_dupe() => log
log.duplicate.push(ctx.note.into_log_note()) .duplicate
} .push(ctx.dupes.into_iter().next().unwrap().note.into_log_note()),
DupeResolution::Duplicate if !ctx.has_first_field() => { DupeResolution::Duplicate if !ctx.has_first_field() => {
log.empty_first_field.push(ctx.note.into_log_note()) log.empty_first_field.push(ctx.note.into_log_note())
} }
DupeResolution::Duplicate => self.add_note(ctx, log)?, DupeResolution::Duplicate => self.add_note(ctx, log)?,
DupeResolution::Update => self.update_with_note(ctx, log)?, DupeResolution::Update => self.update_with_note(ctx, log)?,
DupeResolution::Preserve => log.first_field_match.push(ctx.note.into_log_note()), DupeResolution::Preserve => log
.first_field_match
.push(ctx.dupes.into_iter().next().unwrap().note.into_log_note()),
} }
Ok(()) Ok(())
} }
@ -479,10 +481,6 @@ impl DuplicateUpdateResult {
} }
impl NoteContext<'_> { impl NoteContext<'_> {
fn is_dupe(&self) -> bool {
!self.dupes.is_empty()
}
fn is_guid_dupe(&self) -> bool { fn is_guid_dupe(&self) -> bool {
self.dupes self.dupes
.get(0) .get(0)