Don't send contacts with no data
These are a result of reports that are attached to contacts with no data.
This commit is contained in:
parent
ea33eab9d8
commit
6db5186318
1 changed files with 9 additions and 7 deletions
|
|
@ -28,8 +28,8 @@ func ContactsForOrganization(ctx context.Context, org_id int32) (results []types
|
||||||
return results, fmt.Errorf("by contact ids: %w", err)
|
return results, fmt.Errorf("by contact ids: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
results = make([]types.Contact, len(rows))
|
results = make([]types.Contact, 0)
|
||||||
for i, row := range rows {
|
for _, row := range rows {
|
||||||
contact_emails := contact_emails_by_contact_id[int64(row.ID)]
|
contact_emails := contact_emails_by_contact_id[int64(row.ID)]
|
||||||
emails := make([]string, len(contact_emails))
|
emails := make([]string, len(contact_emails))
|
||||||
for i, e := range contact_emails {
|
for i, e := range contact_emails {
|
||||||
|
|
@ -43,11 +43,13 @@ func ContactsForOrganization(ctx context.Context, org_id int32) (results []types
|
||||||
CanSMS: p.CanSms,
|
CanSMS: p.CanSms,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
results[i] = types.Contact{
|
if row.Name != "" || len(contact_phones) > 0 || len(contact_emails) > 0 {
|
||||||
Emails: emails,
|
results = append(results, types.Contact{
|
||||||
ID: row.ID,
|
Emails: emails,
|
||||||
Name: row.Name,
|
ID: row.ID,
|
||||||
Phones: phones,
|
Name: row.Name,
|
||||||
|
Phones: phones,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return results, nil
|
return results, nil
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue