This commit is contained in:
parent
f04e20426f
commit
586672b279
|
@ -299,19 +299,19 @@ def get_author_followers(_, _info, slug):
|
||||||
|
|
||||||
q = (
|
q = (
|
||||||
select(author_alias)
|
select(author_alias)
|
||||||
.join(alias_author_authors, alias_author_authors.follower_id == author_alias.id)
|
.join(alias_author_authors, alias_author_authors.follower == author_alias.id)
|
||||||
.join(
|
.join(
|
||||||
alias_author_followers, alias_author_followers.author_id == author_alias.id
|
alias_author_followers, alias_author_followers.author == author_alias.id
|
||||||
)
|
)
|
||||||
.filter(author_alias.slug == slug)
|
.filter(author_alias.slug == slug)
|
||||||
.add_columns(
|
.add_columns(
|
||||||
func.count(distinct(alias_shout_author.shout)).label('shouts_stat'),
|
func.count(distinct(alias_shout_author.shout)).label('shouts_stat'),
|
||||||
func.count(distinct(alias_author_authors.author_id)).label('authors_stat'),
|
func.count(distinct(alias_author_authors.author)).label('authors_stat'),
|
||||||
func.count(distinct(alias_author_follower_followers.follower_id)).label(
|
func.count(distinct(alias_author_follower_followers.follower)).label(
|
||||||
'followers_stat'
|
'followers_stat'
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.outerjoin(alias_shout_author, author_alias.id == alias_shout_author.author_id)
|
.outerjoin(alias_shout_author, author_alias.id == alias_shout_author.author)
|
||||||
.group_by(author_alias.id)
|
.group_by(author_alias.id)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ async def accept_invite(_, info, invite_id: int):
|
||||||
invite = session.query(Invite).filter(Invite.id == invite_id).first()
|
invite = session.query(Invite).filter(Invite.id == invite_id).first()
|
||||||
if (
|
if (
|
||||||
invite
|
invite
|
||||||
and invite.author_id is author.id
|
and invite.author_d is author.id
|
||||||
and invite.status is InviteStatus.PENDING.value
|
and invite.status is InviteStatus.PENDING.value
|
||||||
):
|
):
|
||||||
# Add the user to the shout authors
|
# Add the user to the shout authors
|
||||||
|
|
|
@ -191,11 +191,11 @@ def author_follows_topics(author_id: int):
|
||||||
subquery_topic_followers = (
|
subquery_topic_followers = (
|
||||||
select(
|
select(
|
||||||
[
|
[
|
||||||
TopicFollower.topic_id,
|
TopicFollower.topic,
|
||||||
func.count(distinct(TopicFollower.follower)).label('followers_stat'),
|
func.count(distinct(TopicFollower.follower)).label('followers_stat'),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
.group_by(TopicFollower.topic_id)
|
.group_by(TopicFollower.topic)
|
||||||
.alias()
|
.alias()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -48,27 +48,27 @@ def test_query_follows():
|
||||||
expected_queries = [
|
expected_queries = [
|
||||||
mock_session.query(
|
mock_session.query(
|
||||||
mock_Author.id,
|
mock_Author.id,
|
||||||
mock_ShoutAuthor.author_id,
|
mock_ShoutAuthor.author,
|
||||||
mock_AuthorFollower.author_id,
|
mock_AuthorFollower.author,
|
||||||
mock_AuthorFollower.follower_id,
|
mock_AuthorFollower.follower,
|
||||||
)
|
)
|
||||||
.select_from(mock_Author)
|
.select_from(mock_Author)
|
||||||
.outerjoin(mock_ShoutAuthor, mock_Author.id == mock_ShoutAuthor.author_id)
|
.outerjoin(mock_ShoutAuthor, mock_Author.id == mock_ShoutAuthor.author)
|
||||||
.outerjoin(mock_AuthorFollower, mock_Author.id == mock_AuthorFollower.author_id)
|
.outerjoin(mock_AuthorFollower, mock_Author.id == mock_AuthorFollower.author)
|
||||||
.outerjoin(
|
.outerjoin(
|
||||||
mock_AuthorFollower, mock_Author.id == mock_AuthorFollower.follower_id
|
mock_AuthorFollower, mock_Author.id == mock_AuthorFollower.follower
|
||||||
)
|
)
|
||||||
.all,
|
.all,
|
||||||
mock_session.query(
|
mock_session.query(
|
||||||
mock_Topic.id,
|
mock_Topic.id,
|
||||||
mock_ShoutTopic.topic_id,
|
mock_ShoutTopic.topic,
|
||||||
mock_ShoutTopic.topic_id,
|
mock_ShoutTopic.topic,
|
||||||
mock_TopicFollower.topic_id,
|
mock_TopicFollower.topic,
|
||||||
)
|
)
|
||||||
.select_from(mock_Topic)
|
.select_from(mock_Topic)
|
||||||
.outerjoin(mock_ShoutTopic, mock_Topic.id == mock_ShoutTopic.topic_id)
|
.outerjoin(mock_ShoutTopic, mock_Topic.id == mock_ShoutTopic.topic)
|
||||||
.outerjoin(mock_ShoutTopic, mock_Topic.id == mock_ShoutTopic.topic_id)
|
.outerjoin(mock_ShoutTopic, mock_Topic.id == mock_ShoutTopic.topic)
|
||||||
.outerjoin(mock_TopicFollower, mock_Topic.id == mock_TopicFollower.topic_id)
|
.outerjoin(mock_TopicFollower, mock_Topic.id == mock_TopicFollower.topic)
|
||||||
.all,
|
.all,
|
||||||
]
|
]
|
||||||
mock_session.query.assert_has_calls(expected_queries)
|
mock_session.query.assert_has_calls(expected_queries)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user