drafts-resolver-1
Some checks failed
Deploy on push / deploy (push) Failing after 19s

This commit is contained in:
Untone 2024-03-05 18:53:18 +03:00
parent b5727b1b85
commit 5d8c46e76c
2 changed files with 2 additions and 48 deletions

View File

@ -230,51 +230,8 @@ async def load_shouts_by(_, _info, options):
return shouts return shouts
@login_required
@query.field('load_shouts_drafts')
async def load_shouts_drafts(_, info):
user_id = info.context.get('user_id')
shouts = []
if user_id:
q = (
select(Shout)
.options(joinedload(Shout.authors), joinedload(Shout.topics))
.filter(
and_(
Shout.deleted_at.is_not(None),
Shout.published_at.is_(None)
)
)
)
shouts = []
with local_session() as session:
reader = session.query(Author).filter(Author.user == user_id).first()
if isinstance(reader, Author):
q = q.filter(Shout.created_by == reader.id)
q = q.group_by(Shout.id)
for [shout] in session.execute(q).unique():
main_topic = (
session.query(Topic.slug)
.join(
ShoutTopic,
and_(
ShoutTopic.topic == Topic.id,
ShoutTopic.shout == shout.id,
ShoutTopic.main.is_(True),
),
)
.first()
)
if main_topic:
shout.main_topic = main_topic[0]
shouts.append(shout)
return shouts
@login_required
@query.field('load_shouts_feed') @query.field('load_shouts_feed')
@login_required
async def load_shouts_feed(_, info, options): async def load_shouts_feed(_, info, options):
user_id = info.context['user_id'] user_id = info.context['user_id']

View File

@ -10,9 +10,6 @@ type Query {
get_community: Community get_community: Community
get_communities_all: [Community] get_communities_all: [Community]
# editor
get_shouts_drafts: [Shout]
# follower # follower
get_shout_followers(slug: String, shout_id: Int): [Author] get_shout_followers(slug: String, shout_id: Int): [Author]
get_topic_followers(slug: String, topic_id: Int): [Author] get_topic_followers(slug: String, topic_id: Int): [Author]
@ -33,7 +30,7 @@ type Query {
load_shouts_unrated(limit: Int, offset: Int): [Shout] load_shouts_unrated(limit: Int, offset: Int): [Shout]
load_shouts_random_top(options: LoadShoutsOptions): [Shout] load_shouts_random_top(options: LoadShoutsOptions): [Shout]
load_shouts_random_topic(limit: Int!): CommonResult! # { topic shouts } load_shouts_random_topic(limit: Int!): CommonResult! # { topic shouts }
load_shouts_drafts: [Shout] get_shouts_drafts: [Shout]
# topic # topic
get_topic(slug: String!): Topic get_topic(slug: String!): Topic