Performer scene pagination for pairings and studios - #1202
Conversation
|
Thanks for the PR, definitely a useful addition. I've gone a bit back and forth on the implementation. I think not changing the The dataloaders are nice to have, but I'm not sure they're particularly necessary. If it proves to be problematic from traces we can look into adding them back, along with batched scene data loading. |
120d869 to
489fd99
Compare
|
Thanks, I guess I was a little too conservative and it ended up adding a lot of bloat 😅 I've added the new I tried the My suggested solution here is adding |
stashapp/stash-box#1202 was merged so this userscript is no longer useful on versions 0.10.4 and above
stashapp/stash-box#1202 was merged so this userscript is no longer useful on versions 0.10.4 and above
I recently created a userscript that makes it possible to see all scene pairings for two performers instead of just the 10 most recent ones, but pretty soon I realized that this was probably something I should upstream into stash-box itself instead. I also realized that the same limitation appears in the Performers tab when viewing a single studio.
The problem
Performer.scenesbuilds its filter with the page size hardcoded to 10:If two performers have done 200 scenes together, the page looks like they've done ten
What changed in the schema
I went with the extra argument to
Performer.scenesrather than changingscenesto return aQueryScenesResultTypelikequeryScenesdoes, mostly in an attempt to not break any consumers I don't know about: the extra argument is optional so it should behave exactly as before for anyone who may rely on it.Happy to change that if necessary!
Decisions that could benefit from some input
I capped the
per_pagecount to 100. The field is resolved once per performer in aqueryPerformersresult, so it'd multiply with the outer count which is capped to 1000. This may be overly cautious since we already allow fetching 1000 per page, but it'd be easy to drop.Noticed that Infinite added some new data loaders to avoid N+1 queries in #1199 so I pre-emptively added one here that keys off pairs of IDs so it can be reused for the studio/performer pairings as well as performer/performer pairings.
The batch queries count every combination of the two ID sets rather than just the exact pairs asked for, and the caller picks out the ones it wants. That looks wasteful written down, but passing exact pairs meant feeding them through
UNNEST(...) WITH ORDINALITYinside a CTE, and at that point sqlc can't tell they'reuuidcolumns any more and types the whole result asinterface{}. Selecting straight offscene_performerskeeps thedb_type: uuidoverride insqlc.yamlworking. In practice one side of the batch is a single id, so the combinations and the pairs are the same set.I added a new sort value for
SHARED_SCENE_COUNTrather than makeSCENE_COUNTmean something different whenperformed_withis set: I think sorting by how many scenes performers actually have together is more helpful than the existing sort which is keyed off how many total scenes the other performers have. My last commit also makes this the default sort for the pairings tab, but that can easily be dropped if my assumption is too ambitious 😁Testing
I've had the bot write some tests for this and ran several tests against my local dev instance, but I obviously couldn't point it at a live stash-box since it involves backend changes.
AI Disclosure
I had Claude Opus look over the plan and assist with writing tests for this PR