fix(importing): use receiver_names for provisional person display name
resolveReceivers passed the slug as both `sourceRef` AND `lastName`, so an unresolved receiver "smith-john" became a provisional Person with lastName="smith-john" — a regression of the existing senderName→Person contract. Fix: zip the parallel `receiver_person_ids` and `receiver_names` columns by position (the normalizer emits them 1:1 like sender_person_id/sender_name). When the names list is shorter than the slugs list, fall back to slug-as-name for the missing entries. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -211,7 +211,7 @@ public class DocumentImporter {
|
||||
// shrunk set on re-import prunes stale links rather than accumulating them. The
|
||||
// "preserve human edits" rule does NOT extend to these collections.
|
||||
private void applyAuthoritativeAssociations(Document doc, CanonicalSheetReader.Row row) {
|
||||
Set<Person> receivers = resolveReceivers(row.get("receiver_person_ids"));
|
||||
Set<Person> receivers = resolveReceivers(row.get("receiver_person_ids"), row.get("receiver_names"));
|
||||
doc.getReceivers().clear();
|
||||
doc.getReceivers().addAll(receivers);
|
||||
attachTag(doc, row.get("tags"));
|
||||
@@ -256,10 +256,18 @@ public class DocumentImporter {
|
||||
return resolvePerson(slug, rawName);
|
||||
}
|
||||
|
||||
private Set<Person> resolveReceivers(String slugs) {
|
||||
// Zips the parallel `receiver_person_ids` and `receiver_names` columns by position so an
|
||||
// unresolved receiver becomes a provisional Person whose lastName is the human name from
|
||||
// `receiver_names`, not the slug. If the names list is shorter than the slugs list (rare —
|
||||
// canonical data zips them 1:1), missing entries fall back to slug-as-name.
|
||||
private Set<Person> resolveReceivers(String slugs, String names) {
|
||||
List<String> slugList = CanonicalSheetReader.splitList(slugs);
|
||||
List<String> nameList = CanonicalSheetReader.splitList(names);
|
||||
Set<Person> receivers = new LinkedHashSet<>();
|
||||
for (String slug : CanonicalSheetReader.splitList(slugs)) {
|
||||
receivers.add(resolvePerson(slug, slug));
|
||||
for (int i = 0; i < slugList.size(); i++) {
|
||||
String slug = slugList.get(i);
|
||||
String name = i < nameList.size() ? nameList.get(i) : slug;
|
||||
receivers.add(resolvePerson(slug, name));
|
||||
}
|
||||
return receivers;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user