You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
1007 B
26 lines
1007 B
from fastapi import APIRouter
|
|
import backend_fastapi.schemas as schemas
|
|
import backend_fastapi.repositories as repo
|
|
import asyncio
|
|
router = APIRouter()
|
|
|
|
@router.get("/values")
|
|
async def get_values() -> list[schemas.Value]:
|
|
return await repo.get_values()
|
|
|
|
|
|
@router.get("/objects")
|
|
async def get_objects() -> list[schemas.Object]:
|
|
return await repo.get_objects()
|
|
|
|
@router.get("/report")
|
|
async def get_report() -> None:
|
|
import pandas as pd
|
|
values, objects = await asyncio.gather(repo.get_values(), repo.get_objects())
|
|
values = [schemas.Value.model_validate(value).model_dump() for value in values]
|
|
objects = [schemas.Object.model_validate(object).model_dump() for object in objects]
|
|
|
|
df_values= pd.DataFrame(data=values)
|
|
df_objects= pd.DataFrame(data=objects)
|
|
df_type = df_values['id_param'].where(df_values['id_param'] == 3).notnull()
|
|
print(df_values[["id_object","value"]][df_type].set_index("id_object").join(df_objects[["id","id_city"]].set_index("id"),how='inner'))
|