feat(plex): a Surprise reshuffle deals the previous draw last

The rail draws three unseen titles per kind under the sidebar filters; on a
small filtered pool every reshuffle dealt the same few again. The redraw now
sends the draw on screen (exclude=), the server deals the rest of the pool
first and tops up from the excluded titles only when the pool is short, so a
small pool still fills the rail. (The two discover.py baseline entries went
with the rewritten draw.)
This commit is contained in:
2026-10-09 00:06:11 +02:00
parent 6dd82ef5e2
commit 5f42ff61c8
6 changed files with 82 additions and 51 deletions
+3 -1
View File
@@ -625,15 +625,17 @@ export const plexApi = {
return req(`/api/plex/discover?${u.toString()}`);
},
// A fresh random sample for the Surprise-me rail — a new draw every call (the ↻ refetch), narrowed by
// the active filters like the other rails.
// the active filters like the other rails. `exclude` is the previous draw: dealt last, not first.
plexSurprise: (
scope: string,
limit?: number,
filters?: PlexFilters,
lang?: string,
exclude: string[] = [],
): Promise<{ scope: string; items: PlexCard[] }> => {
const u = new URLSearchParams({ scope });
if (limit) u.set("limit", String(limit));
for (const id of exclude) u.append("exclude", id);
if (lang === "hu") u.set("lang", "hu");
if (filters) appendPlexFilters(u, filters);
return req(`/api/plex/surprise?${u.toString()}`);