Merge pull request #78 from Discours/feature/shouts_without_article_layout

excludeLayout filter for loadShouts
This commit is contained in:
Ilya Y 2023-10-01 21:09:42 +03:00 committed by GitHub
commit 6d307f575c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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"): if filters.get("layout"):
q = q.filter(Shout.layout == 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"): if filters.get("author"):
q = q.filter(Shout.authors.any(slug=filters.get("author"))) q = q.filter(Shout.authors.any(slug=filters.get("author")))
if filters.get("topic"): if filters.get("topic"):
@ -123,6 +125,7 @@ async def load_shouts_by(_, info, options):
:param options: { :param options: {
filters: { filters: {
layout: 'audio', layout: 'audio',
excludeLayout: 'article',
visibility: "public", visibility: "public",
author: 'discours', author: 'discours',
topic: 'culture', topic: 'culture',
@ -143,7 +146,10 @@ async def load_shouts_by(_, info, options):
joinedload(Shout.authors), joinedload(Shout.authors),
joinedload(Shout.topics), joinedload(Shout.topics),
).where( ).where(
Shout.deletedAt.is_(None) and_(
Shout.deletedAt.is_(None),
Shout.layout.is_not(None)
)
) )
q = add_stat_columns(q) q = add_stat_columns(q)

View File

@ -217,26 +217,13 @@ input AuthorsBy {
stat: String 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 { input LoadShoutsFilters {
title: String title: String
body: String body: String
topic: String topic: String
author: String author: String
layout: String layout: String
excludeLayout: String
visibility: String visibility: String
days: Int days: Int
reacted: Boolean reacted: Boolean