feat(affiliate): include created_at in dune csv upload#214
feat(affiliate): include created_at in dune csv upload#214kernelwhisperer merged 1 commit intomainfrom
Conversation
📝 WalkthroughWalkthroughThe affiliate program export service now captures and includes a Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
libs/services/src/AffiliateProgramExportService/AffiliateProgramExportServiceImpl.ts (1)
38-50:⚠️ Potential issue | 🟠 MajorSchema changes can be skipped by
exportAffiliateProgramDataIfChangedLine 42 and Line 111 only compare
rowCount+maxUpdatedAt. After addingcreated_atto CSV, old signatures can still match, so upload may be skipped and Dune may never get the new column until unrelated data changes.💡 Proposed fix (signature versioning)
+const CSV_SCHEMA_VERSION = 2 as const; + export class AffiliateProgramExportServiceImpl implements AffiliateProgramExportService { @@ return { rows, signature: { maxUpdatedAt, rowCount: rows.length, + schemaVersion: CSV_SCHEMA_VERSION, }, }; } @@ function isSameSignature( left: AffiliateProgramSignature, right: AffiliateProgramSignature ): boolean { return ( left.rowCount === right.rowCount && - left.maxUpdatedAt === right.maxUpdatedAt + left.maxUpdatedAt === right.maxUpdatedAt && + (left.schemaVersion ?? 1) === (right.schemaVersion ?? 1) ); }Also extend
AffiliateProgramSignatureinAffiliateProgramExportService.tswithschemaVersion: number.Also applies to: 82-87, 106-114
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@libs/services/src/AffiliateProgramExportService/AffiliateProgramExportServiceImpl.ts` around lines 38 - 50, The current signature check in exportAffiliateProgramDataIfChanged (and the related logic in buildAffiliateProgramData / isSameSignature) only uses rowCount and maxUpdatedAt so adding created_at to the CSV can be skipped; update the AffiliateProgramSignature type (in AffiliateProgramExportService.ts) to include a numeric schemaVersion, bump schemaVersion when the CSV schema changes, and ensure the code that computes and compares signatures (buildAffiliateProgramData, isSameSignature, and any checks in exportAffiliateProgramDataIfChanged / upload flow) includes schemaVersion in the equality check so changes to the CSV schema always force an upload.
🧹 Nitpick comments (1)
libs/services/src/AffiliateProgramExportService/AffiliateProgramExportServiceImpl.ts (1)
116-128: Add a short comment thatupdated_atis intentionally excluded from CSVA one-line note near
CSV_HEADERSwould prevent accidental future inclusion ofupdated_atin the external dataset.Based on learnings:
updated_atis intentionally internal for signature (maxUpdatedAt) and should stay out of the Dune CSV.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@libs/services/src/AffiliateProgramExportService/AffiliateProgramExportServiceImpl.ts` around lines 116 - 128, Add a one-line comment immediately above the CSV_HEADERS array stating that `updated_at` is intentionally excluded from the exported CSV because `updated_at` is used internally for signature/state tracking (see maxUpdatedAt) and must not be exported to Dune or other external datasets; update the comment to mention CSV_HEADERS and maxUpdatedAt so future maintainers don't reintroduce `updated_at`.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In
`@libs/services/src/AffiliateProgramExportService/AffiliateProgramExportServiceImpl.ts`:
- Around line 38-50: The current signature check in
exportAffiliateProgramDataIfChanged (and the related logic in
buildAffiliateProgramData / isSameSignature) only uses rowCount and maxUpdatedAt
so adding created_at to the CSV can be skipped; update the
AffiliateProgramSignature type (in AffiliateProgramExportService.ts) to include
a numeric schemaVersion, bump schemaVersion when the CSV schema changes, and
ensure the code that computes and compares signatures
(buildAffiliateProgramData, isSameSignature, and any checks in
exportAffiliateProgramDataIfChanged / upload flow) includes schemaVersion in the
equality check so changes to the CSV schema always force an upload.
---
Nitpick comments:
In
`@libs/services/src/AffiliateProgramExportService/AffiliateProgramExportServiceImpl.ts`:
- Around line 116-128: Add a one-line comment immediately above the CSV_HEADERS
array stating that `updated_at` is intentionally excluded from the exported CSV
because `updated_at` is used internally for signature/state tracking (see
maxUpdatedAt) and must not be exported to Dune or other external datasets;
update the comment to mention CSV_HEADERS and maxUpdatedAt so future maintainers
don't reintroduce `updated_at`.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: c43f9492-51e8-49d3-83b9-ab17217de1cf
📒 Files selected for processing (1)
libs/services/src/AffiliateProgramExportService/AffiliateProgramExportServiceImpl.ts
alfetopito
left a comment
There was a problem hiding this comment.
Do we need any back filling or is this just to expose an already existing field?
Existing, this is a native field from the cms |
This is needed for the new Affiliate dashboard, as requested by Matias, to see affiliate code growth by day.
To Test
DUNE_AFFILIATE_PROGRAM_TABLE_NAME=affiliate_program_data_testSummary by CodeRabbit