-
Notifications
You must be signed in to change notification settings - Fork 498
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: playlist order fix: #1622 #1629
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
export const load = async function ({ locals }) { | ||
const playlists = await locals.prisma.playlist.findMany({ | ||
const playlistMeta = await locals.prisma.playlist.findMany({ |
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.
This is one of the questionable queries. Have to get all playlists first, then get each playlist in a separate query.
}); | ||
const playlists = await Promise.all( | ||
playlistMeta.map(async (playlist) => { | ||
return locals.prisma.playlist.findFirst({ |
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.
One query for every playlist... not ideal.
export const load = async function ({ locals, params }) { | ||
const { p_slug } = params; | ||
const playlist = await locals.prisma.playlist.findUnique({ | ||
const playlistMeta = await locals.prisma.playlist.findUnique({ |
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.
Same thing here, but for a single playlist.
This addresses #1622
Introduced a PlaylistOrder enum to the Playlist model. I thought this might be useful because some playlists we might want to keep ordering exactly as it is on YouTube, some should be reversed and some should be sorted by video published asc / desc.
If this is too complex we can just go with order by Video Published desc
This PR:
What needs review:
syntax-playlist-sort.mp4