From f9edbf1bc0bc105461f03cfd3104d9ec0d49de7f Mon Sep 17 00:00:00 2001 From: nsde Date: Wed, 16 Aug 2023 16:27:16 +0200 Subject: [PATCH] Fixed the autocredits --- rewards/autocredits.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/rewards/autocredits.py b/rewards/autocredits.py index 030c1c6..f7ea815 100644 --- a/rewards/autocredits.py +++ b/rewards/autocredits.py @@ -1,9 +1,15 @@ -from users import UserManager +import os +from dotenv import load_dotenv + +load_dotenv() + +async def get_all_users(client): + users = client[os.getenv('MONGO_NAME', 'nova-test')]['users'] + return users async def update_credits(pymongo_client, settings=None): - manager = UserManager() - users = await manager.get_all_users(pymongo_client) + users = await get_all_users(pymongo_client) if not settings: users.update_many({}, {'$inc': {'credits': 2500}}) @@ -11,4 +17,8 @@ async def update_credits(pymongo_client, settings=None): else: for key, value in settings.items(): users.update_many( - {'level': key}, {'$inc': {'credits': int(value)}}) + {'level': key}, + {'$inc': + {'credits': int(value)} + } + )