fix(affiliate): dune caching & error repoting & linting#216
fix(affiliate): dune caching & error repoting & linting#216kernelwhisperer merged 3 commits intomainfrom
Conversation
📝 WalkthroughWalkthroughThe changes add a comprehensive Jest test suite for the Inversify container factory, export the Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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.
🧹 Nitpick comments (2)
apps/api/src/app/inversify.config.ts (2)
77-93: Double-check the new default TTL.Dropping the fallback from 1 hour to 5 minutes is a 12x increase in cache churn and upstream Dune calls. If that freshness improvement is intentional, fine; otherwise keep the longer default and rely on the env override for shorter-lived environments.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/api/src/app/inversify.config.ts` around lines 77 - 93, The default cache TTL was reduced to 5 minutes which increases upstream Dune calls; revert the DEFAULT_AFFILIATE_STATS_CACHE_TTL_MS to the original 1 hour (3600*1000 ms) in the file and keep the getAffiliateStatsCacheTtlMs() logic and DUNE_AFFILIATE_STATS_CACHE_TTL_MS env override unchanged so environments can still opt into shorter TTLs if desired.
96-228: Avoid two public container entry points unless both are intentional.
getApiContainer()creates a freshContainer, whileapiContainerremains a module-level singleton. Any runtime caller that switches to the factory will get a separateAffiliateStatsServicecache, so the new singleton scope becomes container-local rather than process-wide. If the factory is only for tests, keep it internal; otherwise document that callers must share one container instance.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/api/src/app/inversify.config.ts` around lines 96 - 228, The module currently exposes two public entry points (getApiContainer and apiContainer) causing services bound with inSingletonScope (e.g., AffiliateStatsService bound via affiliateStatsServiceSymbol with inSingletonScope) to become container-local rather than process-wide; fix by making a single public container: either make getApiContainer non-exported (keep only the module-level apiContainer export) or remove the apiContainer export and document/export only the factory and ensure callers share its instance; update usages/tests to obtain the same container (use apiContainer or call a single exported factory wrapper) so AffiliateStatsService and other singletons remain process-wide.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@apps/api/src/app/inversify.config.ts`:
- Around line 77-93: The default cache TTL was reduced to 5 minutes which
increases upstream Dune calls; revert the DEFAULT_AFFILIATE_STATS_CACHE_TTL_MS
to the original 1 hour (3600*1000 ms) in the file and keep the
getAffiliateStatsCacheTtlMs() logic and DUNE_AFFILIATE_STATS_CACHE_TTL_MS env
override unchanged so environments can still opt into shorter TTLs if desired.
- Around line 96-228: The module currently exposes two public entry points
(getApiContainer and apiContainer) causing services bound with inSingletonScope
(e.g., AffiliateStatsService bound via affiliateStatsServiceSymbol with
inSingletonScope) to become container-local rather than process-wide; fix by
making a single public container: either make getApiContainer non-exported (keep
only the module-level apiContainer export) or remove the apiContainer export and
document/export only the factory and ensure callers share its instance; update
usages/tests to obtain the same container (use apiContainer or call a single
exported factory wrapper) so AffiliateStatsService and other singletons remain
process-wide.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 0d78e598-adfe-4476-a266-893c7ad48013
📒 Files selected for processing (4)
apps/api/src/app/inversify.config.spec.tsapps/api/src/app/inversify.config.tsapps/api/src/app/routes/affiliate/affiliate-stats/_address/index.tsapps/api/src/app/routes/affiliate/trader-stats/_address/index.ts
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
09903b0 to
8a40402
Compare
| lastUpdatedAt: result.lastUpdatedAt, | ||
| }); | ||
| } catch (error) { | ||
| fastify.log.error('Error fetching affiliate trader stats:', error); |
There was a problem hiding this comment.
Not urgent, but if both the previous version and the new one are correct, but behave differently, maybe we should create a util function so that we don't make this mistake again?
Please ignore the branch name.
Summary
.inSingletonScope()