mirror of
https://github.com/NovaOSS/nova-api.git
synced 2024-11-29 09:53:57 +01:00
Fixed the autocredits
This commit is contained in:
parent
f6cd1f7aa2
commit
f9edbf1bc0
|
@ -1,9 +1,15 @@
|
||||||
from users import UserManager
|
import os
|
||||||
|
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
|
load_dotenv()
|
||||||
|
|
||||||
|
async def get_all_users(client):
|
||||||
|
users = client[os.getenv('MONGO_NAME', 'nova-test')]['users']
|
||||||
|
return users
|
||||||
|
|
||||||
async def update_credits(pymongo_client, settings=None):
|
async def update_credits(pymongo_client, settings=None):
|
||||||
manager = UserManager()
|
users = await get_all_users(pymongo_client)
|
||||||
users = await manager.get_all_users(pymongo_client)
|
|
||||||
|
|
||||||
if not settings:
|
if not settings:
|
||||||
users.update_many({}, {'$inc': {'credits': 2500}})
|
users.update_many({}, {'$inc': {'credits': 2500}})
|
||||||
|
@ -11,4 +17,8 @@ async def update_credits(pymongo_client, settings=None):
|
||||||
else:
|
else:
|
||||||
for key, value in settings.items():
|
for key, value in settings.items():
|
||||||
users.update_many(
|
users.update_many(
|
||||||
{'level': key}, {'$inc': {'credits': int(value)}})
|
{'level': key},
|
||||||
|
{'$inc':
|
||||||
|
{'credits': int(value)}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in a new issue