fix(admin/analytics): coerce Neon int8 strings to Number() in overvie…#2412
Conversation
…w + ETL summary Neon returns PostgreSQL BIGINT (int8) as JavaScript strings to avoid precision loss. raw sql<number> is a TS-only hint — COUNT/SUM results from raw SQL come back as strings at runtime. Drizzle's count() adds ::int cast internally, but sql`count(...)` and sql`sum(...)` do not. TypeBox t.Number() rejects string values so response validation failed. Coerce totalBrands, withEmbedding, completed, failed, totalItemsIngested.
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 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 |
Coverage Report for Expo Unit Tests Coverage (./apps/expo)
File CoverageNo changed files found. |
Coverage Report for API Unit Tests Coverage (./packages/api)
File CoverageNo changed files found. |
There was a problem hiding this comment.
Pull request overview
Fixes admin analytics response validation failures caused by Neon returning PostgreSQL BIGINT (int8) aggregate results as strings at runtime (despite sql<number> being a TS-only hint). The change ensures the /admin/analytics/catalog endpoints return actual number values that satisfy the TypeBox response schemas.
Changes:
- Coerce
totalBrandsin/catalog/overviewtoNumber(...). - Coerce
withEmbedding(and use the coerced value in coverage percentage math) in/catalog/overview. - Coerce ETL summary aggregates (
completed,failed,totalItemsIngested) toNumber(...)in/catalog/etl.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…w + ETL summary
Neon returns PostgreSQL BIGINT (int8) as JavaScript strings to avoid precision loss. raw sql is a TS-only hint — COUNT/SUM results from raw SQL come back as strings at runtime. Drizzle's count() adds ::int cast internally, but sql
count(...)and sqlsum(...)do not.TypeBox t.Number() rejects string values so response validation failed. Coerce totalBrands, withEmbedding, completed, failed, totalItemsIngested.
Description
Closes #
Type of change
Area(s) affected
apps/expo)packages/api)apps/landing)apps/guides).github/)Testing
curlor Postman)Screenshots / recordings
Pre-merge checklist
bun format && bun lintpasses with no errorsbun check-typespasses with no errorsfeat:,fix:,chore:, etc.)