v3: search engine, responsive header with compact user menu
This commit is contained in:
@@ -112,6 +112,26 @@ export function getPlaylist(
|
||||
return { ...playlist, dumps: visibleDumps };
|
||||
}
|
||||
|
||||
export function searchPlaylists(
|
||||
query: string,
|
||||
limit: number,
|
||||
requestingUserId?: string,
|
||||
): Playlist[] {
|
||||
if (!query.trim()) return [];
|
||||
const pattern = `%${query}%`;
|
||||
const searchClause = `(p.title LIKE ? OR p.description LIKE ?)`;
|
||||
|
||||
const rows = requestingUserId
|
||||
? db.prepare(
|
||||
`SELECT ${PLAYLIST_SELECT} WHERE (p.is_public = 1 OR p.user_id = ?) AND ${searchClause} ORDER BY p.created_at DESC LIMIT ?;`,
|
||||
).all(requestingUserId, pattern, pattern, limit)
|
||||
: db.prepare(
|
||||
`SELECT ${PLAYLIST_SELECT} WHERE p.is_public = 1 AND ${searchClause} ORDER BY p.created_at DESC LIMIT ?;`,
|
||||
).all(pattern, pattern, limit);
|
||||
|
||||
return rows.filter(isPlaylistRow).map(playlistRowToApi);
|
||||
}
|
||||
|
||||
export function listPlaylistsByUser(
|
||||
userId: string,
|
||||
requestingUserId: string | null,
|
||||
|
||||
Reference in New Issue
Block a user