perf(scenes): lista serwisu z tagiem idzie po mniejszej stronie
Gdy serwis ma mniej scen niz najmniejszy wybrany tag, sort po indeksie serwisu, a tag jako filtr. fullmovies + blowjob 15,2 s -> 0,21 s, big-tits 5,3 s -> 0,04 s; rzadki tag 0,26 -> 0,55 s. Te same wyniki. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
dcde8c8d66
commit
9ee15dc934
1 changed files with 15 additions and 1 deletions
|
|
@ -764,7 +764,21 @@ def list_scenes(
|
||||||
).all()
|
).all()
|
||||||
id_by_slug = {slug: tid for slug, tid, _ in tag_rows}
|
id_by_slug = {slug: tid for slug, tid, _ in tag_rows}
|
||||||
if sort == "release_date" and tag_rows:
|
if sort == "release_date" and tag_rows:
|
||||||
tag_sort_id = min(tag_rows, key=lambda r: r[2] or 0)[1]
|
smallest = min(tag_rows, key=lambda r: r[2] or 0)
|
||||||
|
tag_sort_id = smallest[1]
|
||||||
|
# Ekran serwisu z tagiem: idziemy po mniejszej stronie. Gdy serwis ma mniej scen
|
||||||
|
# niz najmniejszy tag, przejscie po indeksie tagu przez caly katalog szukalo
|
||||||
|
# rzadkich scen serwisu (fullmovies 53 tys. + blowjob 555 tys.: 2-17 s,
|
||||||
|
# zgloszenie 80da1ce7). Wtedy sort po indeksie serwisu (origin_sort nizej), a tag
|
||||||
|
# jako zwykly filtr: blowjob 36 ms, rzadki tag z przejsciem calego serwisu ~0,1 s.
|
||||||
|
if origin and ":" in origin and not q:
|
||||||
|
from app.models.source_stats import SourceStats
|
||||||
|
|
||||||
|
origin_scenes = session.execute(
|
||||||
|
select(SourceStats.scenes).where(SourceStats.origin == origin)
|
||||||
|
).scalar()
|
||||||
|
if origin_scenes and origin_scenes < (smallest[2] or 0):
|
||||||
|
tag_sort_id = None
|
||||||
for slug in tag_slug_list:
|
for slug in tag_slug_list:
|
||||||
tag_id = id_by_slug.get(slug)
|
tag_id = id_by_slug.get(slug)
|
||||||
if tag_id is None:
|
if tag_id is None:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue