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)} + } + )