2023-08-19 13:30:46 +02:00
|
|
|
import os
|
2023-08-17 13:11:35 +02:00
|
|
|
import sys
|
2023-08-19 13:30:46 +02:00
|
|
|
|
|
|
|
project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
|
|
|
|
sys.path.append(project_root)
|
|
|
|
|
2023-08-17 13:11:35 +02:00
|
|
|
from api.db.users import UserManager
|
2023-08-07 14:55:53 +02:00
|
|
|
|
2023-08-19 13:30:46 +02:00
|
|
|
manager = UserManager()
|
2023-08-07 14:55:53 +02:00
|
|
|
|
2023-08-19 13:30:46 +02:00
|
|
|
async def update_credits(settings=None):
|
|
|
|
users = await manager.get_all_users()
|
2023-08-07 14:55:53 +02:00
|
|
|
|
2023-08-06 02:14:46 +02:00
|
|
|
if not settings:
|
2023-08-19 13:30:46 +02:00
|
|
|
await users.update_many({}, {'$inc': {'credits': 2500}})
|
2023-08-06 02:14:46 +02:00
|
|
|
|
|
|
|
else:
|
|
|
|
for key, value in settings.items():
|
2023-08-19 13:30:46 +02:00
|
|
|
await users.update_many(
|
2023-08-17 13:11:35 +02:00
|
|
|
{'level': key}, {'$inc': {'credits': int(value)}})
|
2023-08-19 13:30:46 +02:00
|
|
|
|
|
|
|
get_all_users = manager.get_all_users
|