This commit is contained in:
@@ -45,7 +45,7 @@ def get_author(_, _info, slug='', author_id=None):
|
||||
if bool(slug):
|
||||
q = select(Author).where(Author.slug == slug)
|
||||
if author_id:
|
||||
q = select(Author).where(Author.id == int(author_id))
|
||||
q = select(Author).where(Author.id == author_id)
|
||||
|
||||
[author, ] = get_authors_with_stat(q, ratings=True)
|
||||
except Exception as exc:
|
||||
@@ -204,10 +204,8 @@ def get_author_followers(_, _info, slug: str):
|
||||
|
||||
q = (
|
||||
select(author_alias)
|
||||
.join(alias_author_authors, alias_author_authors.follower == int(author_alias.id))
|
||||
.join(
|
||||
alias_author_followers, alias_author_followers.author == int(author_alias.id)
|
||||
)
|
||||
.join(alias_author_authors, alias_author_authors.follower == author_alias.id)
|
||||
.join(alias_author_followers, alias_author_followers.author == author_alias.id)
|
||||
.filter(author_alias.slug == slug)
|
||||
.add_columns(
|
||||
func.count(distinct(alias_shout_author.shout)).label('shouts_stat'),
|
||||
|
@@ -186,8 +186,8 @@ def author_unfollow(follower_id, slug):
|
||||
def get_topic_followers(_, _info, slug: str, topic_id: int) -> List[Author]:
|
||||
q = select(Author)
|
||||
q = (
|
||||
q.join(TopicFollower, TopicFollower.follower == int(Author.id))
|
||||
.join(Topic, Topic.id == int(TopicFollower.topic))
|
||||
q.join(TopicFollower, TopicFollower.follower == Author.id)
|
||||
.join(Topic, Topic.id == TopicFollower.topic)
|
||||
.filter(or_(Topic.slug == slug, Topic.id == topic_id))
|
||||
)
|
||||
return get_authors_with_stat(q)
|
||||
|
@@ -351,8 +351,8 @@ async def load_reactions_by(_, info, by, limit=50, offset=0):
|
||||
|
||||
q = (
|
||||
select(Reaction, Author, Shout)
|
||||
.join(Author, Reaction.created_by == int(Author.id))
|
||||
.join(Shout, Reaction.shout == int(Shout.id))
|
||||
.join(Author, Reaction.created_by == Author.id)
|
||||
.join(Shout, Reaction.shout == Shout.id)
|
||||
)
|
||||
|
||||
# calculate counters
|
||||
@@ -430,7 +430,7 @@ async def reacted_shouts_updates(follower_id: int, limit=50, offset=0) -> List[S
|
||||
# Shouts where follower reacted
|
||||
q2 = (
|
||||
select(Shout)
|
||||
.join(Reaction, Reaction.shout_id == int(Shout.id))
|
||||
.join(Reaction, Reaction.shout_id == Shout.id)
|
||||
.options(joinedload(Shout.reactions), joinedload(Shout.authors))
|
||||
.filter(Reaction.created_by == follower_id)
|
||||
.group_by(Shout.id)
|
||||
|
@@ -207,7 +207,7 @@ async def load_shouts_drafts(_, info):
|
||||
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 == int(reader.id))
|
||||
q = q.filter(Shout.created_by == reader.id)
|
||||
q = q.group_by(Shout.id)
|
||||
for [shout] in session.execute(q).unique():
|
||||
main_topic = (
|
||||
@@ -240,16 +240,16 @@ async def load_shouts_feed(_, info, options):
|
||||
reader = session.query(Author).filter(Author.user == user_id).first()
|
||||
if reader:
|
||||
reader_followed_authors = select(AuthorFollower.author).where(
|
||||
AuthorFollower.follower == int(reader.id)
|
||||
AuthorFollower.follower == reader.id
|
||||
)
|
||||
reader_followed_topics = select(TopicFollower.topic).where(
|
||||
TopicFollower.follower == int(reader.id)
|
||||
TopicFollower.follower == reader.id
|
||||
)
|
||||
|
||||
subquery = (
|
||||
select(Shout.id)
|
||||
.where(Shout.id == int(ShoutAuthor.shout))
|
||||
.where(Shout.id == int(ShoutTopic.shout))
|
||||
.where(Shout.id == ShoutAuthor.shout)
|
||||
.where(Shout.id == ShoutTopic.shout)
|
||||
.where(
|
||||
(ShoutAuthor.author.in_(reader_followed_authors))
|
||||
| (ShoutTopic.topic.in_(reader_followed_topics))
|
||||
|
@@ -189,7 +189,7 @@ def author_follows_authors(author_id: int):
|
||||
def author_follows_topics(author_id: int):
|
||||
q = (
|
||||
select(Topic).select_from(
|
||||
join(Topic, TopicFollower, Topic.id == int(TopicFollower.topic))
|
||||
join(Topic, TopicFollower, Topic.id == TopicFollower.topic)
|
||||
).where(TopicFollower.follower == author_id)
|
||||
)
|
||||
|
||||
|
Reference in New Issue
Block a user