rlt_salary/app.py

30 lines
721 B
Python

from app import MongoDB, aggregate_salaries, Settings
import asyncio
import json
settings = Settings()
client = MongoDB(str(settings.DB_URI))
db = client.client[settings.DATABASE_NAME]
collection = db[settings.COLLECTION_NAME]
json_str = '''
{
"dt_from": "2022-09-01T00:00:00",
"dt_upto": "2022-12-31T23:59:00",
"group_type": "month"
}
'''
async def main(json_str):
data = json.loads(json_str)
dt_from = data["dt_from"]
dt_upto = data["dt_upto"]
group_type = data["group_type"]
result = await aggregate_salaries(collection, dt_from, dt_upto, group_type)
print(result['dataset'], len(result['dataset']))
print(result['labels'], len(result['labels']))
asyncio.run(main(json_str))