Skip to content

fix(export): treat any engagement as exported - #2925

Merged
malek10xdev merged 3 commits into
mainfrom
fix/export-engagement-presence
Oct 2, 2026
Merged

malek10xdev merged 3 commits into
mainfrom
fix/export-engagement-presence

Conversation

@malek10xdev

@malek10xdev malek10xdev commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

The exported side of the export split only matched EXPORT rows, so a contact that already had another engagement row landed in the unit count again.

  • Add getActivatedContacts: a contact counts as exported as soon as it has any engagement row. EXISTS keeps it at one row per contact even with several engagement rows.
  • Redefine the non-exported queries as contacts with no engagement row at all (dropped the type predicate, kept the LEFT JOIN + IS NULL).
  • verifyCredits reads the activated set instead of the exported one. The two sets stay a partition of the selection, so the file, the response fields and the 402/266 gates are unchanged.
  • SELECT_EXPORTED_CONTACTS / getExportedContacts are untouched; they no longer have a caller, left for a separate cleanup.

Tests

  • contacts-export-split.test.ts: only contacts with no engagement row count as units; every selected contact reaches the file; the whole file is handed to registerExportedContacts so an activated contact still gets an EXPORT row; when units run out, activated contacts are kept and the rest trimmed.
  • pg-contacts.test.ts: pins the new SQL (EXISTS, no type filter, scoping, ids variant) and the redefined non-exported SQL, plus a guard that the exported lookup still filters on EXPORT.

Checked against the local DB with a 16-contact user (3 exported, 3 enriched including one with a duplicate engagement row, rest untouched): activated 6, not activated 10, and the two sets sum to 16 with no overlap.

The exported side of the export split only matched EXPORT rows, so a contact
that already had another engagement row landed in the charged set again.

Adds getActivatedContacts, which treats any engagement row as the exported
side, and redefines the non-exported queries as contacts with no engagement
row at all. The two sets stay a partition of the selection, so the file, the
response fields and the gates are unchanged.

SELECT_EXPORTED_CONTACTS and getExportedContacts are left in place; they no
longer have a caller.
@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Coverage Report

✅ Passed

Commit: e244141

Summary

Name Stmts Branch Funcs Lines
🟡 Total 48.7% 47.4% 54.5% 49%
All files
Name Stmts Branch Funcs Lines
🟡 backend/src/controllers/contacts.controller.ts 63.4% 48.3% 77.8% 64.3%
🔴 backend/src/db/pg/PgContacts.ts 40.4% 13.3% 51.7% 39.2%
No coverage changes
Name Stmts Branch Funcs Lines
🟡 backend/src/controllers/contacts.controller.ts 63.4% 48.3% 77.8% 64.3%
🔴 backend/src/db/pg/PgContacts.ts 40.4% 13.3% 51.7% 39.2%

Generated by Test Coverage Reporter for commit e244141

@malek10xdev
malek10xdev merged commit 0b84b27 into main Oct 2, 2026
15 checks passed
@malek10xdev
malek10xdev deleted the fix/export-engagement-presence branch October 2, 2026 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant