Skip to content

Conversation

@kernelwhisperer
Copy link
Contributor

@kernelwhisperer kernelwhisperer commented Feb 4, 2026

This is needed because we will have 2 sets of dashboards for each environment

Summary by CodeRabbit

  • Chores
    • Refactored configuration management to use environment variables instead of hardcoded values, improving deployment flexibility for affiliate program and stats services.

@kernelwhisperer kernelwhisperer requested a review from a team February 4, 2026 16:05
@kernelwhisperer kernelwhisperer self-assigned this Feb 4, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 4, 2026

📝 Walkthrough

Walkthrough

The changes migrate static configuration values from hardcoded constants to dynamic configuration functions that read environment variables. Two services are refactored: AffiliateProgramExportService and AffiliateStatsService, with configuration constants moved to config.ts modules featuring environment variable validation.

Changes

Cohort / File(s) Summary
AffiliateProgramExportService Configuration
libs/services/src/AffiliateProgramExportService/AffiliateProgramExportService.config.ts
Added getAffiliateProgramTableName() function that reads and validates DUNE_AFFILIATE_PROGRAM_TABLE_NAME environment variable, throwing an error if missing.
AffiliateProgramExportService Implementation
libs/services/src/AffiliateProgramExportService/AffiliateProgramExportServiceImpl.ts
Replaced static AFFILIATE_PROGRAM_TABLE_NAME constant with dynamic getAffiliateProgramTableName() call; updated imports and error message references.
AffiliateStatsService Configuration
libs/services/src/AffiliateStatsService/AffiliateStatsService.config.ts
Created new config module with getDuneQueryIds() function that validates DUNE_QUERY_ID_TRADER_STATS and DUNE_QUERY_ID_AFFILIATE_STATS environment variables, plus pagination constants DUNE_PAGE_SIZE and DUNE_MAX_ROWS.
AffiliateStatsService Constants Removal
libs/services/src/AffiliateStatsService/AffiliateStatsService.constants.ts
Removed exported constants DUNE_QUERY_IDS, DUNE_PAGE_SIZE, and DUNE_MAX_ROWS; these are now in config.ts.
AffiliateStatsService Implementation
libs/services/src/AffiliateStatsService/AffiliateStatsServiceImpl.ts
Updated imports from constants.ts to config.ts; replaced static DUNE_QUERY_IDS with dynamic getDuneQueryIds() calls for both query ID references.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 Hop-hop, now our configs dance,
No more static in a trance!
Env vars whisper their sweet names,
While constants shuffle off the frame. 🌱

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: dune ids as env vars' directly and clearly summarizes the main change: making Dune IDs configurable via environment variables instead of hardcoded constants.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/dune-ids-as-env-vars

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.

@@ -0,0 +1,27 @@
export function getDuneQueryIds(): {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just wondering if validation should be re-run every time we need to read the value, or if it could run only once at server startup. I've usually wrapped env variable in a class with some schema validation or something similar, but a more naive approach might be:

const duneQueryIds = getDuneQueryIds();

export const DUNE_QUERY_ID_TRADER_STATS = duneQueryIds.traderStats;
export const DUNE_QUERY_ID_AFFILIATE_STATS  = duneQueryIds.affiliateStats;

The same applies to getAffiliateProgramTableName.

Minor issue, so I'm approving anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, of course, the problem is that this server is also run by other teams, e.g. Aave so the behavior I wanted to achieve was to error at runtime, when hitting the endpoints, and not at start-up.

@kernelwhisperer kernelwhisperer merged commit f30427b into main Feb 4, 2026
9 checks passed
@kernelwhisperer kernelwhisperer deleted the feat/dune-ids-as-env-vars branch February 4, 2026 17:24
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.

4 participants