nova-api/rewards/autocredits.py

16 lines
432 B
Python
Raw Normal View History

2023-08-06 02:14:46 +02:00
async def get_all_users(client):
users = client['nova-core']['users']
return users
2023-08-07 14:55:53 +02:00
async def update_credits(pymongo_client, settings=None):
users = await get_all_users(pymongo_client)
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)}})