logs-update-shout-5
All checks were successful
Deploy on push / deploy (push) Successful in 59s

This commit is contained in:
2025-02-02 21:57:51 +03:00
parent ffb75e53f7
commit 0347b6f5ff
3 changed files with 34 additions and 4 deletions

View File

@@ -173,3 +173,21 @@ async def load_shouts_with_topic(_, info, slug: str, options) -> List[Shout]:
except Exception as error:
logger.debug(error)
return []
def apply_filters(q, filters):
"""
Применяет фильтры к запросу
"""
logger.info(f"Applying filters: {filters}")
if filters.get("published"):
q = q.filter(Shout.published_at.is_not(None))
logger.info("Added published filter")
if filters.get("topic"):
topic_slug = filters["topic"]
q = q.join(ShoutTopic).join(Topic).filter(Topic.slug == topic_slug)
logger.info(f"Added topic filter: {topic_slug}")
return q