rlt_salary/app.py

30 lines
721 B
Python
Raw Normal View History

2024-02-27 20:21:36 +01:00
from app import MongoDB, aggregate_salaries, Settings
import asyncio
import json
settings = Settings()
client = MongoDB(str(settings.DB_URI))
2024-02-27 20:21:36 +01:00
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']))
2024-02-27 20:21:36 +01:00
asyncio.run(main(json_str))