excludeLayout filter for loadShouts

This commit is contained in:
Igor Lobanov 2023-10-01 19:27:08 +02:00
parent a32a18893e
commit 3677874879
2 changed files with 8 additions and 15 deletions

View File

@ -60,6 +60,8 @@ def apply_filters(q, filters, user_id=None):
if filters.get("layout"):
q = q.filter(Shout.layout == filters.get("layout"))
if filters.get('excludeLayout'):
q = q.filter(Shout.layout != filters.get("excludeLayout"))
if filters.get("author"):
q = q.filter(Shout.authors.any(slug=filters.get("author")))
if filters.get("topic"):
@ -123,6 +125,7 @@ async def load_shouts_by(_, info, options):
:param options: {
filters: {
layout: 'audio',
excludeLayout: 'article',
visibility: "public",
author: 'discours',
topic: 'culture',
@ -143,7 +146,10 @@ async def load_shouts_by(_, info, options):
joinedload(Shout.authors),
joinedload(Shout.topics),
).where(
Shout.deletedAt.is_(None)
and_(
Shout.deletedAt.is_(None),
Shout.layout.is_not(None)
)
)
q = add_stat_columns(q)

View File

@ -217,26 +217,13 @@ input AuthorsBy {
stat: String
}
input ShoutsFilterBy {
slug: String
title: String
body: String
topic: String
topics: [String]
author: String
authors: [String]
layout: String
visibility: String
days: Int
stat: String
}
input LoadShoutsFilters {
title: String
body: String
topic: String
author: String
layout: String
excludeLayout: String
visibility: String
days: Int
reacted: Boolean