Running black on all files
This commit is contained in:
1 parent
3237824e83
commit
740dfc97c7
5 files changed
+63
-20
No files matched your search
@@ -57,9 +57,14 @@ async def get_by_sku(db: AsyncSession, sku: str) -> AugmentedPart | None:
|
||||
return result.scalars().first()
|
||||
|
||||
|
||||
async def list_all(db: AsyncSession, skip: int = 0, limit: int = 100) -> list[AugmentedPart]:
|
||||
async def list_all(
|
||||
db: AsyncSession, skip: int = 0, limit: int = 100
|
||||
) -> list[AugmentedPart]:
|
||||
result = await db.execute(
|
||||
select(AugmentedPart).order_by(AugmentedPart.description).offset(skip).limit(limit)
|
||||
select(AugmentedPart)
|
||||
.order_by(AugmentedPart.description)
|
||||
.offset(skip)
|
||||
.limit(limit)
|
||||
)
|
||||
return list(result.scalars().all())
|
||||
|
||||
@@ -88,7 +93,9 @@ async def list_filtered(
|
||||
q = select(AugmentedPart)
|
||||
if description.strip():
|
||||
term = f"%{description.strip()}%"
|
||||
q = q.where(or_(AugmentedPart.description.ilike(term), AugmentedPart.sku.ilike(term)))
|
||||
q = q.where(
|
||||
or_(AugmentedPart.description.ilike(term), AugmentedPart.sku.ilike(term))
|
||||
)
|
||||
if colour_id is not None:
|
||||
q = q.where(AugmentedPart.colour_id == colour_id)
|
||||
if manufacturer_id is not None:
|
||||
@@ -118,7 +125,9 @@ async def count_filtered(
|
||||
q = select(func.count()).select_from(AugmentedPart)
|
||||
if description.strip():
|
||||
term = f"%{description.strip()}%"
|
||||
q = q.where(or_(AugmentedPart.description.ilike(term), AugmentedPart.sku.ilike(term)))
|
||||
q = q.where(
|
||||
or_(AugmentedPart.description.ilike(term), AugmentedPart.sku.ilike(term))
|
||||
)
|
||||
if colour_id is not None:
|
||||
q = q.where(AugmentedPart.colour_id == colour_id)
|
||||
if manufacturer_id is not None:
|
||||
@@ -141,13 +150,17 @@ async def get_unlinked_imported_parts_filtered(
|
||||
limit: int = 50,
|
||||
) -> list[ImportedPart]:
|
||||
q = select(ImportedPart).where(
|
||||
ImportedPart.InventoryID.not_in(select(augmented_part_imported_parts.c.imported_part_id))
|
||||
ImportedPart.InventoryID.not_in(
|
||||
select(augmented_part_imported_parts.c.imported_part_id)
|
||||
)
|
||||
)
|
||||
if description.strip():
|
||||
q = q.where(ImportedPart.Description.ilike(f"%{description.strip()}%"))
|
||||
if colour.strip():
|
||||
q = q.where(ImportedPart.TBXColour.ilike(f"%{colour.strip()}%"))
|
||||
result = await db.execute(q.order_by(ImportedPart.InventoryID).offset(skip).limit(limit))
|
||||
result = await db.execute(
|
||||
q.order_by(ImportedPart.InventoryID).offset(skip).limit(limit)
|
||||
)
|
||||
return list(result.scalars().all())
|
||||
|
||||
|
||||
|
||||
@@ -63,7 +63,10 @@ async def list_filtered(
|
||||
if description.strip():
|
||||
term = f"%{description.strip()}%"
|
||||
q = q.where(
|
||||
or_(ImportedPart.Description.ilike(term), ImportedPart.InventoryID.ilike(term))
|
||||
or_(
|
||||
ImportedPart.Description.ilike(term),
|
||||
ImportedPart.InventoryID.ilike(term),
|
||||
)
|
||||
)
|
||||
q = _apply_sort(q, sort, direction)
|
||||
result = await db.execute(q.offset(skip).limit(limit))
|
||||
@@ -93,7 +96,10 @@ async def count_filtered(db: AsyncSession, description: str = "") -> int:
|
||||
if description.strip():
|
||||
term = f"%{description.strip()}%"
|
||||
q = q.where(
|
||||
or_(ImportedPart.Description.ilike(term), ImportedPart.InventoryID.ilike(term))
|
||||
or_(
|
||||
ImportedPart.Description.ilike(term),
|
||||
ImportedPart.InventoryID.ilike(term),
|
||||
)
|
||||
)
|
||||
result = await db.execute(q)
|
||||
return result.scalar_one()
|
||||
|
||||
Reference in new issue
Block a user