This commit is contained in:
parent
bb55cfaefe
commit
c1adaf3ed6
|
@ -68,6 +68,7 @@ class Shout(Base):
|
|||
body = Column(String, nullable=False, comment="Body")
|
||||
slug = Column(String, unique=True)
|
||||
cover = Column(String, nullable=True, comment="Cover image url")
|
||||
cover_caption = Column(String, nullable=True, comment="Cover image alt caption")
|
||||
lead = Column(String, nullable=True)
|
||||
description = Column(String, nullable=True)
|
||||
title = Column(String, nullable=True)
|
||||
|
|
|
@ -173,7 +173,10 @@ async def get_author(_, _info, slug="", user=None, author_id=None):
|
|||
q = add_author_stat_columns(q)
|
||||
|
||||
authors = get_authors_from_query(q)
|
||||
return authors[0]
|
||||
if authors:
|
||||
return authors.pop()
|
||||
else:
|
||||
return {"error": "cant find author"}
|
||||
|
||||
|
||||
@query.field("load_authors_by")
|
||||
|
@ -201,15 +204,19 @@ async def load_authors_by(_, _info, by, limit, offset):
|
|||
|
||||
@query.field("get_author_followed")
|
||||
async def get_author_followed(_, _info, slug="", user=None, author_id=None) -> List[Author]:
|
||||
# First, we need to get the author_id for the given slug
|
||||
with local_session() as session:
|
||||
author_id_query = None
|
||||
if slug:
|
||||
author_id_query = select(Author.id).where(Author.slug == slug)
|
||||
author_id = session.execute(author_id_query).scalar()
|
||||
elif user:
|
||||
author_id_query = select(Author.id).where(Author.user == user)
|
||||
if not author_id:
|
||||
with local_session() as session:
|
||||
author_id = session.execute(author_id_query).scalar()
|
||||
|
||||
if author_id is None:
|
||||
raise ValueError("Author not found")
|
||||
|
||||
return await followed_authors(author_id)
|
||||
else:
|
||||
return await followed_authors(author_id) # Author[]
|
||||
|
||||
|
||||
@query.field("get_author_followers")
|
||||
|
|
|
@ -126,6 +126,7 @@ type Shout {
|
|||
lang: String
|
||||
community: String
|
||||
cover: String
|
||||
cover_caption: String
|
||||
layout: String
|
||||
version_of: String
|
||||
visibility: ShoutVisibility
|
||||
|
|
Loading…
Reference in New Issue
Block a user