From 5f018c92052319725631586cb1a798246258bf4d Mon Sep 17 00:00:00 2001 From: Servbot91 Date: Sun, 28 Dec 2025 17:18:52 -0500 Subject: [PATCH 1/2] Correct random sort logic If no sort field is specified in GraphQL the server defaults to date created (descending). This incorrectly weighs the random sort results which creates bias towards newer content. Adding the random sort field corrects this. --- plugins/StashRandomButton/random_button.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/StashRandomButton/random_button.js b/plugins/StashRandomButton/random_button.js index 5920e0de..c82fd998 100644 --- a/plugins/StashRandomButton/random_button.js +++ b/plugins/StashRandomButton/random_button.js @@ -19,7 +19,7 @@ async function randomGlobal(entity, idField, redirectPrefix, internalFilter) { const realEntityPlural = getPlural(entity); - let filter = { per_page: 1 }; + let filter = { per_page: 1, sort: "random" }; let variables = { filter }; let filterArg = ""; let filterVar = ""; @@ -45,7 +45,7 @@ if (!totalCount) { alert("No results found."); return; } const randomIndex = Math.floor(Math.random() * totalCount); - let itemVars = { filter: { per_page: 1, page: randomIndex + 1 } }; + let itemVars = { filter: { per_page: 1, page: randomIndex + 1, sort: "random" } }; if (internalFilter) itemVars.internal_filter = internalFilter; const itemQuery = ` query Find${realEntityPlural}($filter: FindFilterType${filterArg}) { From 1693d9925db21ca433ac19a8bf872e1a52324d4f Mon Sep 17 00:00:00 2001 From: DogmaDragon <103123951+DogmaDragon@users.noreply.github.com> Date: Mon, 29 Dec 2025 02:47:47 +0200 Subject: [PATCH 2/2] Bump version --- plugins/StashRandomButton/random_button.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/StashRandomButton/random_button.yml b/plugins/StashRandomButton/random_button.yml index 230763ba..abc79885 100644 --- a/plugins/StashRandomButton/random_button.yml +++ b/plugins/StashRandomButton/random_button.yml @@ -1,6 +1,6 @@ name: RandomButton description: Adds a button to quickly jump to a random scene, image, performer, studio, group, tag, or gallery, both on overview and internal entity pages. -version: 2.0.1 +version: 2.0.2 url: https://discourse.stashapp.cc/t/randombutton/1809 ui: requires: []