-
Notifications
You must be signed in to change notification settings - Fork 300
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
Raw SQL query for fetching users #381
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@ellipsis-dev wdyt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Looks good to me! Reviewed everything up to b06fabf in 1 minute and 13 seconds
More details
- Looked at
688
lines of code in10
files - Skipped
0
files when reviewing. - Skipped posting
4
drafted comments based on config settings.
1. apps/backend/src/prisma-client.tsx:74
- Draft comment:
Consider checking ifrow_to_json
is necessary here, as the data might already be in JSON format. This could potentially simplify the query. - Reason this comment was not posted:
Confidence changes required:30%
The use ofPrisma.sql
andPrisma.raw
in therawQueryArray
function is correct, but the use ofrow_to_json
might not be necessary if the data is already in JSON format. However, this is not a critical issue.
2. apps/backend/src/app/api/v1/users/crud.tsx:238
- Draft comment:
Consider adding additional error handling or validation to ensure that the query results are as expected, especially when dealing with complex JSON structures. - Reason this comment was not posted:
Confidence changes required:40%
ThegetUserQuery
function constructs a raw SQL query using Prisma's SQL template literals. The use ofjsonb_build_object
andto_jsonb
is appropriate for constructing JSON objects from SQL query results. However, the function could benefit from additional error handling or validation to ensure that the query results are as expected.
3. apps/backend/src/app/api/v1/users/crud.tsx:209
- Draft comment:
Using a fallback value of 0 might not be appropriate. Consider using a more meaningful default value or handling the case where no events are found more explicitly. - Reason this comment was not posted:
Confidence changes required:50%
ThegetUserLastActiveAtMillis
function uses a fallback value of 0, which might not be appropriate for all use cases. It would be better to use a more meaningful default value or handle the case where no events are found more explicitly.
4. apps/backend/src/prisma-client.tsx:56
- Draft comment:
Consider adding additional type safety checks to ensure that all queries are valid before execution. This can help prevent runtime errors. - Reason this comment was not posted:
Confidence changes required:30%
TherawQueryAll
function filters out undefined queries usingisNotNull
, which is a good practice. However, the function could benefit from additional type safety checks to ensure that all queries are valid before execution.
Workflow ID: wflow_EYa54591KLvRVWFZ
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
isAdminKeyValid: projectId && superSecretAdminKey && requestType === "admin" ? checkApiKeySetQuery(projectId, { superSecretAdminKey }) : undefined, | ||
}; | ||
const queriesResults = await rawQueryAll(bundledQueries); | ||
console.log("AAAAAAAAA", queriesResults, bundledQueries); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the console.log
statement to avoid unnecessary logging in production.
* dev: (138 commits) Raw project query (stack-auth#382) Require pagination cursor to be UUID Fix unit tests Fix users query Log error when selected team member has no team chore: update package versions Raw SQL query for fetching users (stack-auth#381) Better 429 request logging Fix STACK-SERVER-NH Only fetch keys that are required for the access type Improved OTel spans Better traceSpan signature Even more OTel spans Add display name to span attributes More OTel spans Update backend TypeScript target chore: update package versions removed GET team transaction fixed smtp config bug Insert final newline on file save ... # Conflicts: # .github/workflows/docker-build.yaml # apps/backend/package.json # apps/backend/prisma/seed.ts # apps/backend/sentry.client.config.ts # apps/backend/src/polyfills.tsx # apps/dashboard/sentry.client.config.ts # apps/dashboard/src/app/(main)/(protected)/(outside-dashboard)/projects/page-client.tsx # apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/auth-methods/providers.tsx # apps/dashboard/src/components/data-table/user-table.tsx # apps/dashboard/src/components/version-alerter.tsx # apps/dashboard/src/polyfills.tsx # examples/cjs-test/package.json # examples/demo/src/app/page-client.tsx # examples/middleware/package.json # examples/partial-prerendering/package.json # package.json # packages/stack/package.json # packages/stack/src/generated/quetzal-translations.ts # packages/stack/src/lib/stack-app.ts # pnpm-lock.yaml
Important
Introduces raw SQL queries for efficient user data fetching, optimizing backend query execution in
crud.tsx
andprisma-client.tsx
.getUserQuery
incrud.tsx
for raw SQL user fetching.getUser
to userawQuery
for optimized data retrieval.rawQueryAll
inprisma-client.tsx
for batch query execution.getUserLastActiveAtMillis
to includeprojectId
parameter.getUsersLastActiveAtMillis
to use raw SQL for efficiency.isNotNull
utility function inobjects.tsx
.defaults.js
to includeTemplateLiteral *
in ignored nodes.This description was created by for 1a0afff. It will automatically update as commits are pushed.