Repository navigation
fix(admin): devpass timeseries 404 + legacy sub history - #2223
Conversation
The DevPass timeseries chart 404'd because Hono matches routes in
registration order: `/devpass/{orgId}` was declared before
`/devpass/timeseries`, so the literal path was captured as
`orgId="timeseries"` and the org lookup returned 404.
Subscribers from before the `subscription_*` → `dev_plan_*` rename
also showed an empty Subscription history because the detail and
listing queries only matched `dev_plan_*` types. Include the legacy
`subscription_start/cancel/end` rows for the same orgs.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (3)
📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThe PR updates DevPass admin metrics endpoints to include legacy ChangesDevPass Admin Metrics Legacy Support
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
🚥 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.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/api/src/routes/admin.ts`:
- Around line 8087-8181: The timeseries handler (getDevpassTimeseries) only
considers dev_plan_* transactions (DEV_PLAN_TX_TYPES, the initial MIN(...) query
that anchors startDate, the revenuePerDay filter, and the EXISTS check in
costPerDay) so legacy subscription_* rows are omitted; update the logic to treat
pre-rename subscription rows as equivalent by expanding DEV_PLAN_TX_TYPES (or
adding a new set) to include 'subscription_start' (and any related subscription
types used elsewhere), use that set in the initial MIN(...) query that computes
oldest startDate, use it in the revenuePerDay where clause (inArray(...)), and
update the EXISTS subquery in the costPerDay where clause to check for either
dev_plan_start OR subscription_start (or to use the same set) so legacy-only
subscribers are included in the default range, revenue, and "ever had DevPass"
org check.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: e8de9434-58b6-4d3a-8972-4f8da53febc3
⛔ Files ignored due to path filters (1)
ee/admin/src/lib/api/v1.d.tsis excluded by!**/v1.d.ts
📒 Files selected for processing (1)
apps/api/src/routes/admin.ts
Anchor the default startDate, the revenuePerDay filter, and the cost EXISTS check on `dev_plan_*` OR (`subscription_*` AND personal org). Without this, pre-rename DevPass subscribers were missing from the chart's range, revenue total, and "ever had DevPass" cost cohort. Scoped to personal orgs because `subscription_*` types are still written today by non-personal org Pro subs in stripe.ts; including them unconditionally would over-count org Pro revenue. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
Two bugs in the admin DevPass page:
Subscriber not found. Hono matches routes in registration order, so/devpass/{orgId}(registered first) was capturing/devpass/timeseriesasorgId="timeseries"and the org lookup returned 404. Moved the timeseries handler registration above the{orgId}handler.subscription_*→dev_plan_*rename showedSubscription history (0)even when active (e.g.subscription_startrow with$29/Pro subscription started). The detail and listing queries only matcheddev_plan_*types. Now also include legacysubscription_start/cancel/endrows so the history populates andsubscribedSinceanchors to the correct first start.Test plan
/devpassin admin — chart loads (noFailed to load DevPass timeseriesbanner).subscription_start(e.g.hxJxePnwiH0kXHoVZMKb) — Subscription history shows that row, "Subscribed" date populated.dev_plan_*rows — history still shows them; no regressions.🤖 Generated with Claude Code
Summary by CodeRabbit