This commit is contained in:
parent
168a7079f6
commit
01d7dadd78
|
@ -5,6 +5,7 @@
|
||||||
- resolvers: queries and mutations revision and renaming
|
- resolvers: queries and mutations revision and renaming
|
||||||
- resolvers: delete_topic(slug) implemented
|
- resolvers: delete_topic(slug) implemented
|
||||||
- resolvers: added get_shout_followers
|
- resolvers: added get_shout_followers
|
||||||
|
- resolvers: load_shouts_by filters implemented
|
||||||
|
|
||||||
[0.2.15]
|
[0.2.15]
|
||||||
- schema: Shout.created_by removed
|
- schema: Shout.created_by removed
|
||||||
|
|
|
@ -9,7 +9,7 @@ from orm.author import AuthorFollower, Author
|
||||||
from orm.topic import TopicFollower, Topic
|
from orm.topic import TopicFollower, Topic
|
||||||
from orm.community import CommunityAuthor as CommunityFollower, Community
|
from orm.community import CommunityAuthor as CommunityFollower, Community
|
||||||
from orm.reaction import Reaction, ReactionKind
|
from orm.reaction import Reaction, ReactionKind
|
||||||
from orm.shout import Shout, ShoutAuthor, ShoutTopic
|
from orm.shout import Shout, ShoutAuthor, ShoutTopic, ShoutVisibility
|
||||||
from services.search import SearchService
|
from services.search import SearchService
|
||||||
from services.viewed import ViewedStorage
|
from services.viewed import ViewedStorage
|
||||||
|
|
||||||
|
@ -122,13 +122,11 @@ async def load_shouts_by(_, info, options):
|
||||||
:param info:GraphQLInfo
|
:param info:GraphQLInfo
|
||||||
:param options: {
|
:param options: {
|
||||||
filters: {
|
filters: {
|
||||||
layout: 'audio',
|
layouts: ['audio', 'video', ..],
|
||||||
visibility: "public",
|
visibility: "public",
|
||||||
author: 'discours',
|
author: 'discours',
|
||||||
topic: 'culture',
|
topic: 'culture',
|
||||||
title: 'something',
|
time_ago: 1234567 // unixtime
|
||||||
body: 'something else',
|
|
||||||
days: 30
|
|
||||||
}
|
}
|
||||||
offset: 0
|
offset: 0
|
||||||
limit: 50
|
limit: 50
|
||||||
|
@ -152,12 +150,27 @@ async def load_shouts_by(_, info, options):
|
||||||
|
|
||||||
filters = options.get("filters")
|
filters = options.get("filters")
|
||||||
if filters:
|
if filters:
|
||||||
# with local_session() as session:
|
layouts = filters.get("layouts")
|
||||||
# TODO: some filtering logix?
|
if layouts:
|
||||||
pass
|
q = q.filter(Shout.layout.in_(layouts))
|
||||||
|
by_author = filters.get("author")
|
||||||
|
if by_author:
|
||||||
|
q = q.filter(Shout.authors.contains(by_author))
|
||||||
|
by_topic = filters.get("topic")
|
||||||
|
if by_topic:
|
||||||
|
q = q.filter(Shout.topics.contains(by_topic))
|
||||||
|
by_visibility = {
|
||||||
|
"authors": ShoutVisibility.AUTHORS,
|
||||||
|
"community": ShoutVisibility.COMMUNITY,
|
||||||
|
"public": ShoutVisibility.PUBLIC,
|
||||||
|
}[filters.get("visibility")]
|
||||||
|
if by_visibility:
|
||||||
|
q = q.filter(Shout.visibility > by_visibility)
|
||||||
|
by_time_ago = filters.get("time_ago")
|
||||||
|
if by_time_ago:
|
||||||
|
q = q.filter(Shout.created_at < by_time_ago)
|
||||||
|
|
||||||
order_by = options.get("order_by", Shout.published_at)
|
order_by = options.get("order_by", Shout.published_at)
|
||||||
|
|
||||||
query_order_by = desc(order_by) if options.get("order_by_desc", True) else asc(order_by)
|
query_order_by = desc(order_by) if options.get("order_by_desc", True) else asc(order_by)
|
||||||
offset = options.get("offset", 0)
|
offset = options.get("offset", 0)
|
||||||
limit = options.get("limit", 10)
|
limit = options.get("limit", 10)
|
||||||
|
|
|
@ -257,14 +257,11 @@ input ShoutsFilterBy {
|
||||||
}
|
}
|
||||||
|
|
||||||
input LoadShoutsFilters {
|
input LoadShoutsFilters {
|
||||||
title: String
|
|
||||||
body: String
|
|
||||||
topic: String
|
topic: String
|
||||||
author: String
|
author: String
|
||||||
layouts: [String]
|
layouts: [String]
|
||||||
visibility: String
|
visibility: String
|
||||||
time_ago: Int
|
time_ago: Int
|
||||||
reacted: Boolean
|
|
||||||
}
|
}
|
||||||
|
|
||||||
input LoadShoutsOptions {
|
input LoadShoutsOptions {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user