author-topic-filter-fix
Some checks failed
Deploy on push / deploy (push) Failing after 2m2s

This commit is contained in:
2025-09-03 12:44:24 +03:00
parent c24d3a4b70
commit f99f14759c
2 changed files with 13 additions and 33 deletions

View File

@@ -182,6 +182,9 @@ async def get_authors_with_stats(
.where(Shout.published_at.is_not(None))
.distinct() # Избегаем дубликатов авторов
)
# Указываем что фильтр применен, чтобы избежать сброса сортировки по умолчанию
default_sort_applied = True
logger.debug(f"✅ Topic filter applied for: {topic_value}")
# Применяем фильтрацию по параметрам из by
if by:
@@ -196,7 +199,9 @@ async def get_authors_with_stats(
# vars for statistics sorting
stats_sort_field = None
default_sort_applied = False
# НЕ сбрасываем default_sort_applied если он уже установлен для фильтра по топику
if not default_sort_applied:
default_sort_applied = False
if by:
if "order" in by:
@@ -674,7 +679,12 @@ async def get_authors_with_stats(
raise
# Используем универсальную функцию для кеширования запросов
cached_result = await cached_query(cache_key, fetch_authors_with_stats)
# Для фильтра по топику принудительно обновляем кеш (временное решение для отладки)
force_refresh = by is not None and by.get("topic") is not None
if force_refresh and by:
logger.debug(f"🚨 Force refresh enabled for topic filter: {by.get('topic')}")
cached_result = await cached_query(cache_key, fetch_authors_with_stats, force_refresh=force_refresh)
logger.debug(f"Cached result: {cached_result}")
return cached_result