|
|
|
|
@ -13,6 +13,7 @@ from src.database.service import CommonParameters, search_filter_sort_paginate
|
|
|
|
|
from src.overhaul_activity.utils import get_material_cost, get_service_cost
|
|
|
|
|
from src.overhaul_scope.model import OverhaulScope
|
|
|
|
|
from src.overhaul_scope.service import get as get_session
|
|
|
|
|
from src.scope_equipment.model import MasterEquipment
|
|
|
|
|
|
|
|
|
|
from .model import OverhaulActivity
|
|
|
|
|
from .schema import (OverhaulActivityCreate, OverhaulActivityRead,
|
|
|
|
|
@ -36,6 +37,7 @@ async def get(
|
|
|
|
|
return result.scalar()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def get_all(
|
|
|
|
|
*,
|
|
|
|
|
common: CommonParameters,
|
|
|
|
|
@ -46,7 +48,7 @@ async def get_all(
|
|
|
|
|
query = (
|
|
|
|
|
Select(OverhaulActivity)
|
|
|
|
|
.where(OverhaulActivity.overhaul_scope_id == overhaul_session_id)
|
|
|
|
|
.options(joinedload(OverhaulActivity.equipment))
|
|
|
|
|
.options(joinedload(OverhaulActivity.equipment).options(joinedload(MasterEquipment.parent).options(joinedload(MasterEquipment.parent))))
|
|
|
|
|
.options(selectinload(OverhaulActivity.overhaul_scope))
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
@ -62,6 +64,8 @@ async def get_all(
|
|
|
|
|
|
|
|
|
|
results = await search_filter_sort_paginate(model=query, **common)
|
|
|
|
|
|
|
|
|
|
##raise Exception(results['items'][0].equipment.parent.__dict__)
|
|
|
|
|
|
|
|
|
|
return results
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -69,7 +73,7 @@ async def get_all_by_session_id(*, db_session: DbSession, overhaul_session_id):
|
|
|
|
|
query = (
|
|
|
|
|
Select(OverhaulActivity)
|
|
|
|
|
.where(OverhaulActivity.overhaul_scope_id == overhaul_session_id)
|
|
|
|
|
.options(joinedload(OverhaulActivity.equipment))
|
|
|
|
|
.options(joinedload(OverhaulActivity.equipment).options(MasterEquipment.parent).options(MasterEquipment.parent))
|
|
|
|
|
.options(selectinload(OverhaulActivity.overhaul_scope))
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|