nova-api/rewards/autocredits.py

18 lines
499 B
Python
Raw Normal View History

import sys
# Weird hack because PYTHON IS GOOD LANGUAGE :))))
sys.path.append('../')
from api.db.users import UserManager
2023-08-07 14:55:53 +02:00
async def update_credits(pymongo_client, settings=None):
manager = UserManager()
users = await manager.get_all_users(pymongo_client)
2023-08-07 14:55:53 +02:00
2023-08-06 02:14:46 +02:00
if not settings:
users.update_many({}, {'$inc': {'credits': 2500}})
2023-08-06 02:14:46 +02:00
else:
for key, value in settings.items():
2023-08-07 14:55:53 +02:00
users.update_many(
{'level': key}, {'$inc': {'credits': int(value)}})