From b196ec67d47ae61d1262f74e3d9a5d8b184cb889 Mon Sep 17 00:00:00 2001 From: cmyui Date: Sun, 4 Aug 2024 04:25:24 +0200 Subject: [PATCH] Move pipeline to be per-user --- main.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 63162cd..9e21cef 100755 --- a/main.py +++ b/main.py @@ -100,8 +100,8 @@ async def recalc_ranks() -> None: country_ranking_keys = await get_all_country_rankings_keys(rank_key) - async with redis.pipeline() as pipe: - for user in users: + for user in users: + async with redis.pipeline() as pipe: inactive_days = ( (start_time - user["latest_pp_awarded"]) / 60 / 60 / 24 ) @@ -134,7 +134,7 @@ async def recalc_ranks() -> None: await pipe.zrem(rank_key, user["id"]) await pipe.zrem(user_country_rank_key, user["id"]) - await pipe.execute() + await pipe.execute() print(f"Recalculated all ranks in {time.time() - start_time:.2f} seconds")