Skip to content

feat(affiliate): include created_at in dune csv upload#214

Merged
kernelwhisperer merged 1 commit intomainfrom
feat/include-created-at-in-affiliate
Apr 28, 2026
Merged

feat(affiliate): include created_at in dune csv upload#214
kernelwhisperer merged 1 commit intomainfrom
feat/include-created-at-in-affiliate

Conversation

@kernelwhisperer
Copy link
Copy Markdown
Contributor

@kernelwhisperer kernelwhisperer commented Apr 27, 2026

This is needed for the new Affiliate dashboard, as requested by Matias, to see affiliate code growth by day.

To Test

  1. Clone
  2. Set DUNE_AFFILIATE_PROGRAM_TABLE_NAME=affiliate_program_data_test
  3. Start the server
  4. Check the column is present in the table
image

Summary by CodeRabbit

  • New Features
    • Affiliate program exports now include creation timestamps, allowing users to track when each program was originally established.

@kernelwhisperer kernelwhisperer requested a review from a team April 27, 2026 15:33
@kernelwhisperer kernelwhisperer self-assigned this Apr 27, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 27, 2026

📝 Walkthrough

Walkthrough

The affiliate program export service now captures and includes a created_at timestamp in its CSV output. The AffiliateProgramRow data structure gains a created_at field that maps from affiliate.createdAt, and the CSV generation logic extends to include this new column in both headers and data rows.

Changes

Cohort / File(s) Summary
Affiliate Export Timestamp
libs/services/src/AffiliateProgramExportService/AffiliateProgramExportServiceImpl.ts
Added created_at field to AffiliateProgramRow type, populated from affiliate.createdAt during row construction, and included in CSV export headers and output rows.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A timestamp hops into the export stream,
Created-at fields fulfill the dream,
CSV columns dance in perfect line,
Affiliate data now tracks through time! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(affiliate): include created_at in dune csv upload' directly and accurately summarizes the main change: adding a created_at column to the Dune CSV export for affiliate program data.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/include-created-at-in-affiliate

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 | 🟠 Major

Schema changes can be skipped by exportAffiliateProgramDataIfChanged

Line 42 and Line 111 only compare rowCount + maxUpdatedAt. After adding created_at to 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 AffiliateProgramSignature in AffiliateProgramExportService.ts with schemaVersion: 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 that updated_at is intentionally excluded from CSV

A one-line note near CSV_HEADERS would prevent accidental future inclusion of updated_at in the external dataset.

Based on learnings: updated_at is 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

📥 Commits

Reviewing files that changed from the base of the PR and between 7835e93 and 7dbea56.

📒 Files selected for processing (1)
  • libs/services/src/AffiliateProgramExportService/AffiliateProgramExportServiceImpl.ts

Copy link
Copy Markdown
Collaborator

@alfetopito alfetopito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need any back filling or is this just to expose an already existing field?

@kernelwhisperer
Copy link
Copy Markdown
Contributor Author

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

@kernelwhisperer kernelwhisperer merged commit 0b2acaf into main Apr 28, 2026
9 checks passed
@kernelwhisperer kernelwhisperer deleted the feat/include-created-at-in-affiliate branch April 28, 2026 06:37
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.

3 participants