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

feat(pnjs): load progress with less queries #235

Merged
merged 4 commits into from
Jul 31, 2024

Conversation

joelhooks
Copy link
Collaborator

perf

Copy link

linear bot commented Jul 30, 2024

Copy link

vercel bot commented Jul 30, 2024

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

Name Status Preview Comments Updated (UTC)
course-builder-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 31, 2024 0:14am
course-builder-poc ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 31, 2024 0:14am
course-builder-video-blog ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 31, 2024 0:14am
epic-web-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 31, 2024 0:14am
js-visualized ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 31, 2024 0:14am
pro-aws ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 31, 2024 0:14am
pro-nextjs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 31, 2024 0:14am
value-based-design ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 31, 2024 0:14am

Comment on lines +1022 to +1051
const results: any = await client.execute(sql`
SELECT
cr.id AS resource_id,
cr.type AS resource_type,
cr.fields->>'$.slug' AS resource_slug,
rp.completedAt AS completed_at
FROM
ContentResource workshop
LEFT JOIN
ContentResourceResource crr1 ON workshop.id = crr1.resourceOfId
LEFT JOIN
ContentResource cr1 ON cr1.id = crr1.resourceId
LEFT JOIN
ContentResourceResource crr2 ON cr1.id = crr2.resourceOfId
LEFT JOIN
ContentResource cr2 ON cr2.id = crr2.resourceId
LEFT JOIN
ResourceProgress rp ON rp.resourceId = COALESCE(cr2.id, cr1.id) AND rp.userId = ${user.id}
CROSS JOIN
ContentResource cr
WHERE
(workshop.id = ${moduleIdOrSlug} OR workshop.fields->>'$.slug' = ${moduleIdOrSlug})
AND (
(cr.id = cr1.id AND cr1.type IN ('lesson', 'exercise'))
OR (cr.id = cr2.id AND cr2.type IN ('lesson', 'exercise'))
)
ORDER BY
COALESCE(crr1.position, 0),
COALESCE(crr2.position, 0);
`)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

less querying and data to get what we want

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.

1 participant