✅ Added the base code
This commit is contained in:
parent
aceebf6bf8
commit
0e20615412
23
app.py
23
app.py
|
@ -0,0 +1,23 @@
|
||||||
|
from app import MongoDB, aggregate_salaries, Settings
|
||||||
|
import asyncio
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
|
settings = Settings()
|
||||||
|
client = MongoDB(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):
|
||||||
|
result = await aggregate_salaries()
|
||||||
|
pass
|
||||||
|
|
||||||
|
asyncio.run(main(json_str))
|
|
@ -0,0 +1,2 @@
|
||||||
|
from app.config import Settings
|
||||||
|
from app.database import MongoDB, aggregate_salaries
|
|
@ -0,0 +1,12 @@
|
||||||
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||||
|
|
||||||
|
class Settings(BaseSettings):
|
||||||
|
API_TOKEN_TG: str
|
||||||
|
HOST_MONGODB: str
|
||||||
|
DATABASE_NAME: str
|
||||||
|
COLLECTION_NAME: str
|
||||||
|
USERNAME_MONGO: str
|
||||||
|
PASSWORD_MONGO: str
|
||||||
|
DB_URI: str
|
||||||
|
|
||||||
|
model_config = SettingsConfigDict(env_file='.env', env_file_encoding='utf-8')
|
|
@ -0,0 +1,2 @@
|
||||||
|
from app.database.mongodb import MongoDB
|
||||||
|
from app.database.methods import aggregate_salaries
|
|
@ -0,0 +1,8 @@
|
||||||
|
from typing import List, Tuple
|
||||||
|
|
||||||
|
async def aggregate_salaries(dt_from: str, dt_upto: str, group_type: str) -> Tuple[List[int], List[str]]:
|
||||||
|
pipeline = [
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
|
return {"dataset": None, "labels": None}
|
|
@ -0,0 +1,5 @@
|
||||||
|
from motor.motor_asyncio import AsyncIOMotorClient
|
||||||
|
|
||||||
|
class MongoDB:
|
||||||
|
def __init__(self, url: str):
|
||||||
|
self.client = AsyncIOMotorClient(url)
|
Loading…
Reference in New Issue