return-type-fix
Some checks failed
Deploy to core / deploy (push) Failing after 1m30s

This commit is contained in:
Untone 2024-02-03 17:31:00 +03:00
parent 18521f3fc5
commit d3b2eddf58
3 changed files with 12 additions and 7 deletions

View File

@ -79,14 +79,16 @@ async def update_profile(_, info, profile):
Author.update(author, profile)
session.add(author)
session.commit()
return {'error': None, 'author': author}
return {'error': None, 'author': author}
# TODO: caching query
@query.field('get_authors_all')
async def get_authors_all(_, _info):
authors = []
with local_session() as session:
return session.query(Author).all()
authors = session.query(Author).all()
return authors
def count_author_comments_rating(session, author_id) -> int:

View File

@ -21,6 +21,7 @@ from services.search import search_service
@login_required
async def get_shouts_drafts(_, info):
user_id = info.context['user_id']
shouts = []
with local_session() as session:
author = session.query(Author).filter(Author.user == user_id).first()
if author:
@ -34,7 +35,7 @@ async def get_shouts_drafts(_, info):
.group_by(Shout.id)
)
shouts = [shout for [shout] in session.execute(q).unique()]
return shouts
return shouts
@mutation.field('create_shout')
@ -189,7 +190,7 @@ async def update_shout(_, info, shout_id, shout_input=None, publish=False):
# main topic
main_topic = shout_input.get('main_topic')
if main_topic:
patch_main_topic(main_topic)
patch_main_topic(session, main_topic, shout)
shout_input['updated_at'] = current_time
shout_input['published_at'] = current_time if publish else None

View File

@ -109,11 +109,13 @@ async def get_topic(_, _info, slug):
async def create_topic(_, _info, inp):
with local_session() as session:
# TODO: check user permissions to create topic for exact community
# and actor is permitted to craete it
new_topic = Topic(**inp)
session.add(new_topic)
session.commit()
return {'topic': new_topic}
return {'topic': new_topic}
return {'error': 'cannot create topic'}
@mutation.field('update_topic')
@ -130,6 +132,7 @@ async def update_topic(_, _info, inp):
session.commit()
return {'topic': topic}
return {'error': 'cannot update' }
@mutation.field('delete_topic')
@ -149,8 +152,7 @@ async def delete_topic(_, info, slug: str):
session.commit()
return {}
else:
return {'error': 'access denied'}
return {'error': 'access denied'}
def topic_follow(follower_id, slug):