2023-08-17 13:11:35 +02:00
|
|
|
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):
|
2023-08-17 13:11:35 +02:00
|
|
|
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:
|
2023-08-07 23:28:24 +02:00
|
|
|
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(
|
2023-08-17 13:11:35 +02:00
|
|
|
{'level': key}, {'$inc': {'credits': int(value)}})
|