Refactor getFirst to not depend on our PgAirtableDb abstraction#2620
Conversation
|
Warning Review limit reached
More reviews will be available in 21 minutes and 13 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, 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 include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
✨ 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 |
|
@coderabbitai review @greptileai review |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Get PR details and files changed
gh pr view 2620 --repo bluedotimpact/bluedot --json files,title,body
echo "---FILES---"
gh pr diff 2620 --repo bluedotimpact/bluedotLength of output: 27368
1. In -export function resolveSortConfig<T extends PgTable>(
+function resolveSortConfig<T extends PgTable>(2. No direct tests for All tests in 3. In // at the end of buildWhereClauseInner, before the throw:
if (conditions.length === 0) {
// empty filter object → no constraint (match all rows)
return sql`TRUE`;
}Minor: The Overall the refactor is solid and the new tests are a good improvement over the placeholder that was there before. The points above are all non-blocking. 🧠 Learnings used |
Greptile SummaryThis PR extracts
Confidence Score: 5/5This is a safe refactor — logic is extracted verbatim into a standalone function, the existing wrapper delegates to it unchanged, and the new test suite exercises the full call path including the direct getFirstFromPg route. The extracted getFirstFromPg is a faithful port of the removed code in client.ts with no behavioral changes. All call-sites pass the same filter arguments as before, and the expanded test suite covers the previously untested direct-PgTable path that motivated the extraction. No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant Caller as exercises.ts / resources.ts
participant PgAirtableDb as PgAirtableDb (client.ts)
participant PgQuery as getFirstFromPg (pg-query.ts)
participant Drizzle as Drizzle ORM / Postgres
Note over Caller,PgAirtableDb: Before refactor
Caller->>PgAirtableDb: db.getFirst(table, opts)
PgAirtableDb->>PgAirtableDb: resolveSortConfig()
PgAirtableDb->>PgAirtableDb: buildWhereClause()
PgAirtableDb->>Drizzle: SELECT ... LIMIT 1
Drizzle-->>Caller: result
Note over Caller,PgQuery: After refactor
Caller->>PgQuery: getFirstFromPg(db.pg, table.pg, opts)
PgQuery->>PgQuery: resolveSortConfig()
PgQuery->>PgQuery: buildWhereClause()
PgQuery->>Drizzle: SELECT ... LIMIT 1
Drizzle-->>Caller: result
Note over PgAirtableDb,PgQuery: db.getFirst still works (delegates)
PgAirtableDb->>PgQuery: getFirstFromPg(pgUnrestricted, table.pg, opts)
PgQuery-->>PgAirtableDb: result
Reviews (2): Last reviewed commit: "Address AI comments" | Re-trigger Greptile |
|
@marn-in-prod I would appreciate a retroactive review on this when you get a chance! |
Description
We use
db.getFirstas a guard against issues due to duplicates. Previously, this was tightly coupled to PgAirtableDb. We want to keep using this when we move exercise responses and resource completions to postgres-only, so I'm splitting out agetFirstFromPgin this PR.Issue
#2584
Developer checklist