mirror of
https://github.com/NovaOSS/nova-api.git
synced 2024-11-25 16:33:56 +01:00
25 lines
607 B
Python
25 lines
607 B
Python
import os
|
|
import sys
|
|
|
|
project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
|
|
sys.path.append(project_root)
|
|
|
|
from api.db.users import UserManager
|
|
|
|
manager = UserManager()
|
|
|
|
async def update_credits(settings=None):
|
|
"""Updates the credits of all users."""
|
|
|
|
users = await manager.get_all_users()
|
|
|
|
if not settings:
|
|
await users.update_many({}, {'$inc': {'credits': 2500}})
|
|
|
|
else:
|
|
for key, value in settings.items():
|
|
await users.update_many(
|
|
{'level': key}, {'$inc': {'credits': int(value)}})
|
|
|
|
get_all_users = manager.get_all_users
|