Lead source imports: no duplicates without emails; explee hot leads

origami.chat people have no email, so each import added them again.
Prospects now match on email, then LinkedIn profile, then name at the
same company; companies without a website match by name, and get the
domain when one turns up. explee.com's hot-leads list allows at most 200
per page (500 was refused, so no hot leads became prospects). origami.chat
people's company website is read from identity.website_url. explee.com's
key test no longer says "the key works" twice.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-21 18:33:26 -07:00
co-authored by Claude Opus 5.5
parent 157902f7e2
commit e135288005
5 changed files with 128 additions and 37 deletions
+30
View File
@@ -218,3 +218,33 @@ func TestCRMMatches(t *testing.T) {
}
func itoa(n int64) string { return strconv.FormatInt(n, 10) }
// People from tools without emails (origami.chat) must not be added twice.
func TestAddWithoutEmails(t *testing.T) {
d := openDB(t)
c1, _, _ := AddCompany(d, Company{Name: "DATAGROUP", Source: "origami"}, now)
c2, added, _ := AddCompany(d, Company{Name: "Datagroup", Website: "https://www.datagroup.example/", Source: "origami"}, now)
if added || c2 != c1 {
t.Fatalf("same name, now with a website: %d %d %v", c1, c2, added)
}
if c, _ := GetCompany(d, c1); c.Domain != "datagroup.example" {
t.Errorf("the domain wasn't filled in: %+v", c)
}
p1, _, _ := AddContact(d, Contact{CompanyID: c1, FirstName: "Helge", LastName: "Viehof", LinkedIn: "https://www.linkedin.com/in/helge-v/", Source: "origami"}, now)
if p2, added, _ := AddContact(d, Contact{FirstName: "Helge", LastName: "Viehof", LinkedIn: "http://linkedin.com/in/helge-v", Source: "origami"}, now); added || p2 != p1 {
t.Errorf("same LinkedIn: %d %d %v", p1, p2, added)
}
if p3, added, _ := AddContact(d, Contact{CompanyID: c1, FirstName: "helge", LastName: "viehof", Source: "origami"}, now); added || p3 != p1 {
t.Errorf("same name at the same company: %d %d %v", p1, p3, added)
}
// A later email is filled in; a namesake elsewhere is someone else.
if p4, added, _ := AddContact(d, Contact{FirstName: "Helge", LastName: "Viehof", Email: "helge@datagroup.example", LinkedIn: "linkedin.com/in/helge-v", Source: "hunter"}, now); added || p4 != p1 {
t.Errorf("email added later: %d %d %v", p1, p4, added)
}
if p, _ := GetContact(d, p1); p.Email != "helge@datagroup.example" {
t.Errorf("email not filled in: %+v", p)
}
if _, added, _ := AddContact(d, Contact{FirstName: "Helge", LastName: "Viehof", Source: "origami"}, now); !added {
t.Error("a namesake without a company was merged")
}
}