following-cache-anyway-found
All checks were successful
Deploy on push / deploy (push) Successful in 27s
All checks were successful
Deploy on push / deploy (push) Successful in 27s
This commit is contained in:
parent
3ab42ecb72
commit
ac5674d18f
|
@ -192,7 +192,7 @@ async def get_author_follows(_, _info, slug="", user=None, author_id=0):
|
||||||
logger.debug(f"getting {author_id} follows authors")
|
logger.debug(f"getting {author_id} follows authors")
|
||||||
cached = await redis.execute("GET", rkey)
|
cached = await redis.execute("GET", rkey)
|
||||||
if not cached:
|
if not cached:
|
||||||
authors = author_follows_authors(author_id) # type: ignore
|
authors = author_follows_authors(author_id) # type: ignore
|
||||||
prepared = [author.dict() for author in authors]
|
prepared = [author.dict() for author in authors]
|
||||||
await redis.execute(
|
await redis.execute(
|
||||||
"SET", rkey, json.dumps(prepared, cls=CustomJSONEncoder)
|
"SET", rkey, json.dumps(prepared, cls=CustomJSONEncoder)
|
||||||
|
@ -205,7 +205,7 @@ async def get_author_follows(_, _info, slug="", user=None, author_id=0):
|
||||||
if cached and isinstance(cached, str):
|
if cached and isinstance(cached, str):
|
||||||
topics = json.loads(cached)
|
topics = json.loads(cached)
|
||||||
if not cached:
|
if not cached:
|
||||||
topics = author_follows_topics(author_id) # type: ignore
|
topics = author_follows_topics(author_id) # type: ignore
|
||||||
prepared = [topic.dict() for topic in topics]
|
prepared = [topic.dict() for topic in topics]
|
||||||
await redis.execute(
|
await redis.execute(
|
||||||
"SET", rkey, json.dumps(prepared, cls=CustomJSONEncoder)
|
"SET", rkey, json.dumps(prepared, cls=CustomJSONEncoder)
|
||||||
|
|
|
@ -61,7 +61,7 @@ async def follow(_, info, what, slug):
|
||||||
if isinstance(author_dict, dict):
|
if isinstance(author_dict, dict):
|
||||||
author_id = author_dict.get("id")
|
author_id = author_dict.get("id")
|
||||||
if author_id:
|
if author_id:
|
||||||
follows_ids = [a.get('id') for a in follows]
|
follows_ids = [a.get("id") for a in follows]
|
||||||
if author_id not in follows_ids:
|
if author_id not in follows_ids:
|
||||||
await cache_author(follower_dict)
|
await cache_author(follower_dict)
|
||||||
await notify_follower(follower_dict, author_id, "follow")
|
await notify_follower(follower_dict, author_id, "follow")
|
||||||
|
|
|
@ -149,7 +149,8 @@ async def cache_topic(topic_dict: dict):
|
||||||
# topic not found in the list, so add the new topic with the updated stat field
|
# topic not found in the list, so add the new topic with the updated stat field
|
||||||
follower_follows_topics.append(topic_dict)
|
follower_follows_topics.append(topic_dict)
|
||||||
|
|
||||||
await redis.execute('SET',
|
await redis.execute(
|
||||||
|
"SET",
|
||||||
"SET",
|
"SET",
|
||||||
f"author:{follower_id}:follows-topics",
|
f"author:{follower_id}:follows-topics",
|
||||||
json.dumps(follower_follows_topics),
|
json.dumps(follower_follows_topics),
|
||||||
|
|
|
@ -116,28 +116,28 @@ def after_author_update(_mapper, _connection, author: Author):
|
||||||
def after_topic_follower_insert(_mapper, _connection, target: TopicFollower):
|
def after_topic_follower_insert(_mapper, _connection, target: TopicFollower):
|
||||||
logger.info(target)
|
logger.info(target)
|
||||||
asyncio.create_task(
|
asyncio.create_task(
|
||||||
handle_topic_follower_change(target.topic, target.follower, True) # type: ignore
|
handle_topic_follower_change(target.topic, target.follower, True) # type: ignore
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def after_topic_follower_delete(_mapper, _connection, target: TopicFollower):
|
def after_topic_follower_delete(_mapper, _connection, target: TopicFollower):
|
||||||
logger.info(target)
|
logger.info(target)
|
||||||
asyncio.create_task(
|
asyncio.create_task(
|
||||||
handle_topic_follower_change(target.topic, target.follower, False) # type: ignore
|
handle_topic_follower_change(target.topic, target.follower, False) # type: ignore
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def after_author_follower_insert(_mapper, _connection, target: AuthorFollower):
|
def after_author_follower_insert(_mapper, _connection, target: AuthorFollower):
|
||||||
logger.info(target)
|
logger.info(target)
|
||||||
asyncio.create_task(
|
asyncio.create_task(
|
||||||
handle_author_follower_change(target.author, target.follower, True) # type: ignore
|
handle_author_follower_change(target.author, target.follower, True) # type: ignore
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def after_author_follower_delete(_mapper, _connection, target: AuthorFollower):
|
def after_author_follower_delete(_mapper, _connection, target: AuthorFollower):
|
||||||
logger.info(target)
|
logger.info(target)
|
||||||
asyncio.create_task(
|
asyncio.create_task(
|
||||||
handle_author_follower_change(target.author, target.follower, False) # type: ignore
|
handle_author_follower_change(target.author, target.follower, False) # type: ignore
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user