nova-api/rewards/autocredits.py

15 lines
407 B
Python
Raw Normal View History

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