fix: 订单分页缓存、统计与列表一致、admin-assignments 解析

This commit is contained in:
XingQue
2026-06-24 06:18:47 +08:00
parent c42f979082
commit b33bd3eb18
3 changed files with 123 additions and 96 deletions

View File

@@ -93,6 +93,23 @@ def orders_for_request(request):
return filter_queryset_by_club(Order.query.all(), request, club_field='ClubID')
def paginate_fluent_query(fluent_qs, page, page_size):
"""
FluentQuery 分页。禁用会话缓存,避免 count 后 slice 导致列表为空。
返回 (total, items)。
"""
page = max(1, int(page))
page_size = max(1, min(int(page_size), 100))
counter = fluent_qs._clone()
counter._cache_enabled = False
total = counter.count()
start = (page - 1) * page_size
page_q = fluent_qs._clone()
page_q._cache_enabled = False
page_q._qs = page_q._qs[start:start + page_size]
return total, page_q.to_list()
def filter_user_related_by_club(qs, request, user_club_path='user__ClubID'):
"""按 User.ClubID 过滤打手/管事/商家等关联查询。"""
scope = resolve_club_scope(request)