Communications tab: show matched investors only (v0.1.0:81)
The email-activity panel surfaced every captured message, including cold/ unknown-sender email with no investor association. Gate query_email_activity on EXISTS(email_investor_links) so the panel shows only email tied to a known investor/contact. Capture is unchanged — unmatched email is still stored (metadata-only) and will appear automatically if its sender is later added as an investor; this is a read-side filter only. Graveyard investors are unaffected (their email has a link), so they remain visible/searchable as an audit surface, hidden only from the filter picker.
This commit is contained in:
@@ -405,6 +405,10 @@ def query_email_activity(conn: sqlite3.Connection, *, investor_id: Optional[str]
|
||||
investor (matched fundraising investor) and/or mailbox, with free-text search
|
||||
over subject/snippet/sender. Returns the email rows plus the filter facets.
|
||||
|
||||
Matched-only: the panel shows ONLY email that links to a known investor/contact
|
||||
(an `email_investor_links` row exists). Unmatched cold/unknown-sender email is
|
||||
still captured for completeness but is never surfaced here.
|
||||
|
||||
Soft-delete: an email is live only if it still has a non-tombstoned per-mailbox
|
||||
sighting (`email_account_messages.deleted_at IS NULL`) — the `emails` row itself
|
||||
carries no deleted_at, so deletion lives on the sighting. Direction is decided at
|
||||
@@ -418,7 +422,10 @@ def query_email_activity(conn: sqlite3.Connection, *, investor_id: Optional[str]
|
||||
own.discard("")
|
||||
|
||||
where = ["EXISTS (SELECT 1 FROM email_account_messages eam "
|
||||
"WHERE eam.email_id = e.id AND eam.deleted_at IS NULL)"]
|
||||
"WHERE eam.email_id = e.id AND eam.deleted_at IS NULL)",
|
||||
# Matched-only: surface email that links to a known investor/contact.
|
||||
# Unmatched (unknown-sender) email is captured but never shown here.
|
||||
"EXISTS (SELECT 1 FROM email_investor_links l WHERE l.email_id = e.id)"]
|
||||
params: list = []
|
||||
if account_id:
|
||||
where.append("EXISTS (SELECT 1 FROM email_account_messages eam "
|
||||
|
||||
Reference in New Issue
Block a user