Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: convert database queries to use Drizzle ORM #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

devin-ai-integration[bot]
Copy link

@devin-ai-integration devin-ai-integration bot commented Jan 2, 2025

Convert Database Queries to Use Drizzle ORM

This PR converts all database queries in the router files to use Drizzle ORM's type-safe query builders, replacing raw SQL queries.

Changes

  • Replace raw SQL queries with type-safe Drizzle query builders
  • Add proper null handling for numeric values (?? 0)
  • Maintain consistent date/time string conversions
  • Preserve existing query logic and frontend compatibility

GroupBy Statement Updates

  • bundlers.ts:
    // From: .groupBy(sql`platform, time`)
    // To: .groupBy(sql`COALESCE(${bundlerHourlyMetrics.bundlerName}, 'unknown')\`, sql`time`)
  • factories.ts:
    // From: .groupBy(sql`${factories.name}, time`)
    // To: .groupBy(factories.name, sql`time`)
  • paymasters.ts:
    // From: .groupBy(sql`platform, time`)
    // To: .groupBy(sql`COALESCE(${paymasters.name}, 'unknown')\`, sql`time`)
  • global-stats.ts:
    // From: .groupBy(sql`time, ${globalHourlyMetrics.chainId}`)
    // To: .groupBy(sql`time\`, globalHourlyMetrics.chainId)

Link to Devin run: https://app.devin.ai/sessions/f36d7319d9704224ba1059804c4256f0

- Replace raw SQL queries with type-safe Drizzle query builders
- Add proper null handling for numeric values
- Maintain consistent date/time string conversions
- Preserve existing query logic and frontend compatibility
- Convert queries in address-book, bundlers, factories, paymasters, and global-stats routers

Co-Authored-By: [email protected] <[email protected]>
Copy link
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add "(aside)" to your comment to have me ignore it.
  • Look at CI failures and help fix them

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link

vercel bot commented Jan 2, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
4337-stats-dashboard ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 2, 2025 1:40pm

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.

0 participants