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
[PoC] use limit & offset in cardigann definitions #13996
base: master
Are you sure you want to change the base?
Conversation
This one is quite easy fix, new variables. And for |
Ok, so we throw the maths of Bit of an edge case here, but what happens if someone manually uses (for example)
|
Yeah. variables[".Query.Limit"] = query.Limit.ToString() ?? null;
variables[".Query.Offset"] = query.Offset.ToString() ?? null;
variables[".Query.CurrentPage0"] = Math.Max(0, query.Offset > 0 && query.Limit > 0 ? query.Offset / query.Limit : 0).ToString();
variables[".Query.CurrentPage1"] = Math.Max(1, query.Offset > 0 && query.Limit > 0 ? (query.Offset / query.Limit) + 1 : 1).ToString();
Being integers involved in the math, I'm certain will be page 1. |
3 quick examples:
|
Resolve conflict. @garfield69 thoughts? |
I am not able to make time must time this week to properly read and absorb this topic, but my first thought is that we need to ensure that the limit does not get abused by setting a cap on the limit size, or we risk trashing a site. |
Yea, I was wondering last week if it would be worth implementing a global request delay of 2s, and then this could still be overridden per indexer/definition. I suppose in a similar vein then, we could have a default page cap of 5(?) and limit cap of 500 (1000?). |
Starr has a hard cap of 30 pages or 1000 results whatever is hit first for context Would suggest using that accordingly otherwise you're artificially limiting results defaults of 10 pages / 1000 results seems sane - assumption is 100 results per page |
c0e1549
to
fcb7975
Compare
236457b
to
2de12fa
Compare
schema.json needs updating |
Working now. |
Please use rebase when possible. |
5b6fc20
to
a96bbe4
Compare
@ilike2burnthing I think it's better to use strictly positive integers, but with PageSize should we set minimum 1, since 0 would be the default? |
Sure, whatever makes the most sense. I was just just doing a quick fix to satisfy the check. |
Co-Authored-By: ilike2burnthing <[email protected]>
Co-Authored-By: ilike2burnthing <[email protected]>
a96bbe4
to
9976514
Compare
Hi, just saw this PR. Sorry to make things more complicated. After doing some logging on our tracker and determining that Jackett was using 32% of our total database execution time, we've spent some time optimizing our api (HDInnovations/UNIT3D-Community-Edition#2679). Among other things such as removing a couple of redundant queries and implementing some basic caching, we've changed our pagination from using I would think as trackers in active development get larger in size, that they too will switch to using cursor pagination instead of limit/offset, for the greater efficiency (https://shopify.engineering/pagination-relative-cursors explains the advantages if you're interested). Unfortunately, this concept doesn't correspond directly to torznab's pagination implementation. |
TL;DR - worth looking into further?
This is in response to #13681 (comment), but I completely forgot about until eb93dbb jogged my memory.
It's just a proof of concept rather than an actual PR, as:
From a quick glance at the definitions, two main cases are currently workable:
animeclipseanimetracker - justlimit
, largely pointless but might as well if this does move forwardlimit
andoffset
with single torrents per resultsThen there's:
limit
andoffset
with multiple torrents per resultsThis is broken due to how Jackett handles
limit
. For anilibria,limit=1
will return 1 'result', but it may still have more than 1 magnet. However, Jackett will only show the first magnet.Also, if I use
limit=100
in a torznab search, Jackett shows 100 results, but usinglimit=0
orlimit=
(or performing a keywordless search in Jackett's UI) Jackett shows 190 results, despite the anilibria search URL being the same. Jackett trims any results over thelimit
.Not sure if this can be easily fixed, and whether it's a core issue or just Cardigann.
As for other issues:
not sure if something can be done to allow us to go from:
"{{ if eq .Query.Limit \"0\" }}100{{ else }}{{ .Query.Limit }}{{ end }}"
to:"{{ if .Query.Limit }}{{ .Query.Limit }}{{ else }}100{{ end }}"
or even:"{{ .Query.Limit }}"
as we're HTML-scraping most trackers, they generally use pages rather than an offset, so we'd need to use some method of the following to allow the use of
offset
with them:{{ .Query.Offset }} / {{ .Query.Limit }} + 1
[taken from], but then we start getting into the long overdue [Enhancement] Pagination - Jackett search results vs. tracker(s) search results – Discrepancies & limitations #975.