Adding post-import adjustments
This commit is contained in:
1 parent
c320595423
commit
87019ff2af
6 files changed
+170
-3
No files matched your search
@@ -1,7 +1,9 @@
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.models.associations import augmented_part_imported_parts
|
||||
from app.models.augmented_part import AugmentedPart
|
||||
from app.models.imported_part import ImportedPart
|
||||
|
||||
_RELATIONSHIPS = ["colour", "manufacturer", "scope_model", "part_type", "sub_part_type"]
|
||||
|
||||
@@ -58,6 +60,20 @@ async def update(
|
||||
return ap
|
||||
|
||||
|
||||
async def get_unlinked_imported_parts(db: AsyncSession) -> list[ImportedPart]:
|
||||
"""ImportedParts that have no corresponding AugmentedPart link."""
|
||||
result = await db.execute(
|
||||
select(ImportedPart)
|
||||
.where(
|
||||
ImportedPart.InventoryID.not_in(
|
||||
select(augmented_part_imported_parts.c.imported_part_id)
|
||||
)
|
||||
)
|
||||
.order_by(ImportedPart.InventoryID)
|
||||
)
|
||||
return list(result.scalars().all())
|
||||
|
||||
|
||||
async def delete(db: AsyncSession, ap: AugmentedPart) -> None:
|
||||
await db.delete(ap)
|
||||
await db.commit()
|
||||
Reference in new issue
Block a user