From f99f14759cafd238b6bc914e979cc4d4d88170b1 Mon Sep 17 00:00:00 2001 From: Untone Date: Wed, 3 Sep 2025 12:44:24 +0300 Subject: [PATCH] author-topic-filter-fix --- docs/oauth-setup.md | 32 +------------------------------- resolvers/author.py | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 33 deletions(-) diff --git a/docs/oauth-setup.md b/docs/oauth-setup.md index 416dfc94..79155f6a 100644 --- a/docs/oauth-setup.md +++ b/docs/oauth-setup.md @@ -15,37 +15,7 @@ The platform supports the following OAuth providers: ## Environment Variables -Add the following environment variables to your `.env` file: - -```bash -# Google OAuth -OAUTH_CLIENTS_GOOGLE_ID=your_google_client_id -OAUTH_CLIENTS_GOOGLE_KEY=your_google_client_secret - -# GitHub OAuth -OAUTH_CLIENTS_GITHUB_ID=your_github_client_id -OAUTH_CLIENTS_GITHUB_KEY=your_github_client_secret - -# Facebook OAuth -OAUTH_CLIENTS_FACEBOOK_ID=your_facebook_app_id -OAUTH_CLIENTS_FACEBOOK_KEY=your_facebook_app_secret - -# X (Twitter) OAuth -OAUTH_CLIENTS_X_ID=your_x_client_id -OAUTH_CLIENTS_X_KEY=your_x_client_secret - -# Telegram OAuth -OAUTH_CLIENTS_TELEGRAM_ID=your_telegram_bot_token -OAUTH_CLIENTS_TELEGRAM_KEY=your_telegram_bot_secret - -# VK OAuth -OAUTH_CLIENTS_VK_ID=your_vk_app_id -OAUTH_CLIENTS_VK_KEY=your_vk_secure_key - -# Yandex OAuth -OAUTH_CLIENTS_YANDEX_ID=your_yandex_client_id -OAUTH_CLIENTS_YANDEX_KEY=your_yandex_client_secret -``` +Add the needed environment variables to your `.env` file ## Provider Setup Instructions diff --git a/resolvers/author.py b/resolvers/author.py index 18615fe7..3ef851b6 100644 --- a/resolvers/author.py +++ b/resolvers/author.py @@ -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