fmt+follows-refactored
This commit is contained in:
@@ -20,9 +20,7 @@ DEFAULT_FOLLOWS = {
|
||||
}
|
||||
|
||||
|
||||
async def handle_author_follower_change(
|
||||
author_id: int, follower_id: int, is_insert: bool
|
||||
):
|
||||
async def handle_author_follower_change(author_id: int, follower_id: int, is_insert: bool):
|
||||
logger.info(author_id)
|
||||
author_query = select(Author).select_from(Author).filter(Author.id == author_id)
|
||||
[author] = get_with_stat(author_query)
|
||||
@@ -30,17 +28,13 @@ async def handle_author_follower_change(
|
||||
[follower] = get_with_stat(follower_query)
|
||||
if follower and author:
|
||||
await cache_author(author.dict())
|
||||
await cache_follows(
|
||||
follower.dict(), "author", author.dict(), is_insert
|
||||
) # cache_author(follower_dict) inside
|
||||
await cache_follows(follower.dict(), "author", author.dict(), is_insert) # cache_author(follower_dict) inside
|
||||
await cache_follow_author_change(
|
||||
follower.dict(), author.dict(), is_insert
|
||||
) # cache_author(follower_dict) inside
|
||||
|
||||
|
||||
async def handle_topic_follower_change(
|
||||
topic_id: int, follower_id: int, is_insert: bool
|
||||
):
|
||||
async def handle_topic_follower_change(topic_id: int, follower_id: int, is_insert: bool):
|
||||
logger.info(topic_id)
|
||||
topic_query = select(Topic).filter(Topic.id == topic_id)
|
||||
[topic] = get_with_stat(topic_query)
|
||||
@@ -48,9 +42,7 @@ async def handle_topic_follower_change(
|
||||
[follower] = get_with_stat(follower_query)
|
||||
if follower and topic:
|
||||
await cache_author(follower.dict())
|
||||
await redis.execute(
|
||||
"SET", f"topic:{topic.id}", json.dumps(topic.dict(), cls=CustomJSONEncoder)
|
||||
)
|
||||
await redis.execute("SET", f"topic:{topic.id}", json.dumps(topic.dict(), cls=CustomJSONEncoder))
|
||||
await cache_follows(follower.dict(), "topic", topic.dict(), is_insert)
|
||||
|
||||
|
||||
@@ -84,9 +76,7 @@ def after_reaction_update(mapper, connection, reaction: Reaction):
|
||||
|
||||
# reaction repliers
|
||||
replied_author_subquery = (
|
||||
select(Author)
|
||||
.join(Reaction, Author.id == Reaction.created_by)
|
||||
.where(Reaction.id == reaction.reply_to)
|
||||
select(Author).join(Reaction, Author.id == Reaction.created_by).where(Reaction.id == reaction.reply_to)
|
||||
)
|
||||
authors_with_stat = get_with_stat(replied_author_subquery)
|
||||
for author_with_stat in authors_with_stat:
|
||||
|
Reference in New Issue
Block a user